Skip to content

Memory Analysis

Memory leak detection and heap analysis for identifying memory issues.

Overview

Memory leaks cause applications to consume increasing amounts of RAM over time, leading to OOM kills and poor performance. perfetto-cli detects leaks by analyzing RSS growth trends and provides heap dominator tree analysis.

Commands

memory leak

Detect memory leaks via RSS growth trend analysis.

perfetto-cli -t trace.perfetto-trace -p com.example.app memory leak

Options:

Option Description Default
--growth-threshold <MB/min> Minimum RSS growth rate to flag as leak 5

memory heap

Heap dominator tree analysis — shows which objects are retaining the most memory.

perfetto-cli -t trace.perfetto-trace -p com.example.app memory heap

Workflow

  1. Run memory leak to check for abnormal RSS growth
  2. If a leak is detected, run memory heap to identify the retaining objects
  3. Focus on objects with unexpectedly large retained sizes

Tips

  • Lower --growth-threshold for long-running traces to catch slow leaks
  • Heap analysis requires traces captured with heap profiling enabled
  • Use -f json to track memory metrics across multiple test runs