Android Studio Profiler

On this page 7

Android Studio Profiler is the set of performance analysis tools built into Android Studio that records CPU activity, memory allocation, thread scheduling and power use of an app running on a device or emulator. In mobile performance work, it is the first instrument developers open when an app starts slowly, drops frames, leaks memory or drains the battery, because it connects a visible symptom to the exact method, thread or allocation that causes it.

The Profiler is a front end for lower-level platform tracers such as Perfetto, simpleperf and heapprofd, presented with timelines, flame charts and heap tables. It replaced the older Android Monitor and, in recent releases, organizes its features as task-based recordings rather than one always-on dashboard.

How the profiler collects data

The Profiler attaches to a running app process and either samples it at intervals or instruments it to record every event, then streams the data to the IDE. Sampling has low overhead but can miss short calls; instrumentation captures every method entry and exit but inflates timings substantially.

Which data are available depends on the build. A debuggable build allows every feature, including Java and Kotlin allocation tracking and heap dumps. A profileable build, declared with the profileable manifest element on Android 10 and later, behaves like a release build and gives more realistic timings, but supports fewer recording types.

Build typeRuntime behaviorAvailable recordingsBest for
DebuggableSome ART optimizations disabledAll tasks, including heap dumpsMemory investigations, allocation tracking
ProfileableClose to release behaviorCPU sampling, system trace, native allocationsStartup time, jank, CPU hotspots
Release, not profileableFully optimizedNone from the IDEField measurement with other tools
Build types used for profiling

Profiling tasks and what each reveals

Each Profiler task answers a specific performance question, and choosing the right task is the main skill. The table maps the principal tasks to the questions they answer.

TaskUnderlying dataQuestion answeredOverhead
Capture system activitiesPerfetto system traceWhy are frames late or threads blockedLow
Find CPU hotspotsCallstack sampling or method tracingWhich code consumes CPU timeLow to very high
Track memory consumptionJava, Kotlin or native allocation recordsWhat allocates memory and how oftenMedium
Analyze memory usageHeap dumpWhich objects are retained and by whomPauses the app
View live telemetryPeriodic countersHow CPU and memory trend over timeLow
Main Android Studio Profiler tasks

The system trace is usually the most informative starting point for jank and startup problems. It shows the main thread, the RenderThread, binder calls, lock contention and CPU core frequency on one timeline, so developers can see whether a slow frame came from app code, waiting on another process or a throttled CPU.

For memory, a heap dump lists every object with its shallow and retained size and flags leaked Activity and Fragment instances. Allocation tracking complements it by showing allocation churn, the rapid creation of short-lived objects that triggers frequent garbage collection and stutter.

Reading results: key metrics and views

Profiler output uses a small vocabulary of views, and misreading them is a common source of wrong conclusions. Flame charts and call trees summarize the same samples in different ways.

View or metricWhat it showsTypical pitfall
Flame chartAggregated call stacks, width equals timeReading the horizontal axis as chronology
Top down and bottom upCall tree from callers or from calleesIgnoring self time versus total time
Wall clock timeElapsed time including waitingBlaming CPU code for time spent blocked
Thread timeTime the thread actually ran on a CPUOverlooking I/O or lock waits
Retained sizeMemory freed if the object were collectedConfusing it with shallow size
Views and metrics in profiler results

The distinction between wall clock time and thread time is decisive: a method with long wall time but short thread time is waiting, usually on disk, network or a lock, and optimizing its code will not help.

Frame analysis follows the same logic. At a 60 Hz refresh rate each frame has a budget of about 16.7 ms, at 90 Hz about 11.1 ms and at 120 Hz about 8.3 ms. In a system trace, frames that miss the deadline are marked as janky, and the developer then checks whether the delay sat on the main thread, in RenderThread work or in GPU completion, because each points to a different fix.

How it relates to other performance tools

Android Studio Profiler is a local, developer-side tool and works best alongside field data and automated benchmarks. Perfetto provides deeper trace analysis, Macrobenchmark produces repeatable startup and scrolling numbers, and Android vitals reports what real users experience, such as ANR and crash rates.

  • Perfetto UI opens the same system traces with SQL queries and custom tracks for advanced analysis.
  • Macrobenchmark measures startup and frame timing repeatedly, which suits regression testing in continuous integration.
  • Baseline Profiles are often validated with the Profiler, by comparing startup traces before and after.
  • Xcode Instruments plays the equivalent role for iOS apps.

Limitations and common mistakes

The Profiler changes the behavior it measures, so every reading carries observer overhead. The most frequent errors come from profiling the wrong build or the wrong device.

  • Profiling a debuggable build for timing exaggerates costs because the runtime skips some optimizations.
  • Using instrumented method tracing to judge real speed adds large overhead to small, frequently called methods.
  • Relying on the emulator hides real thermal throttling, slower storage and weaker GPUs of low-end phones.
  • Profiling once ignores variance; repeated recordings on a cold and a warm start are needed.
  • Ignoring JIT warm-up makes the first run look slower than steady state, unless Baseline Profiles are installed.

The idea in brief

Android Studio Profiler is like a medical scanner for an app. When an app feels slow or eats too much battery, a developer connects the phone to the computer and records what the app does second by second.

The recording shows which pieces of code keep the processor busy, how memory fills up and where the app waits for something. Instead of guessing, the developer can point to the exact cause and fix it, then record again to confirm that the problem is gone.

A practical scenario

A team building a shopping app receives complaints that the product list stutters on mid-range phones. A developer installs a profileable release build on a three-year-old test device and records a system trace while scrolling.

The trace shows several frames taking about 35 ms instead of the 16.7 ms needed at 60 Hz. The main thread spends that time decoding product images synchronously. A second recording with allocation tracking reveals heavy bitmap allocation churn that forces frequent garbage collection.

The team moves decoding to a background thread and reuses bitmap memory. A new trace shows nearly all frames within budget, and the Android vitals slow-frame rate for that screen drops in the next release.