On this page
Performance problems hide behind assumptions. "The list is slow because of images" might really be a database query on the main thread. The Profiler replaces guesses with timelines, stacks and allocations. You only need to know which tool answers which question.
Which tool for which question
| Question | Tool / task |
|---|---|
| Why is startup or a screen slow? | System trace (or CPU callstack sampling) |
| Why does scrolling stutter? | System trace: frames, main and RenderThread, jank markers |
| Which functions use the most CPU? | CPU callstack sample / method trace, flame chart |
| Is memory leaking or spiking? | Heap dump, Java/Kotlin allocation tracking |
| What requests are made, and how long do they take? | Network Inspector (App Inspection) |
| What's draining battery? | Power Profiler, Background Task Inspector |
Profile the right build
Debuggable builds behave differently: extra checks and no R8 optimisation. For realistic CPU and timing data, profile a profileable release-like build. Android Studio lets you choose "Profile with low overhead" (profileable) or "Profile with complete data" (debuggable). Use debuggable only when you need the extra detail, such as some memory features.
<application>
<!-- Allows profiling tools to attach to a non-debuggable build -->
<profileable android:shell="true" />
</application>Reading a system trace
- Record a system trace while reproducing the problem, keeping the recording short and focused.
- Find long or red frames in the frame lifecycle and jank tracks.
- Look at the main thread during that frame: what slice spans it?
- Zoom in and follow nested slices down to your code.
Add your own trace sections
import androidx.tracing.trace
fun buildFeed(items: List<Post>): List<FeedRow> = trace("FeedMapper.buildFeed") {
items.map { it.toRow() } // appears as a named slice in system traces
}Named sections make traces readable, so you can see your own code, not just framework calls. Compose also emits composition tracing when the runtime tracing dependency is added.
Memory investigations
- Sawtooth pattern (rise then drop at each GC) is normal. A steady climb across repeated actions suggests a leak.
- Heap dump: filter by class (for example your Activity) and inspect instance counts and references. See Memory Leaks.
- Allocation tracking: find code allocating many short-lived objects during scroll or animation (GC churn causes jank).
Network Inspector
App Inspection's Network Inspector shows each request's URL, timing, size, headers and payload for supported networking libraries such as OkHttp. Use it to spot duplicate requests, oversized payloads and slow endpoints.
Example investigations
Janky list
A system trace showed date formatting with a new formatter per row on main. Fix: format once in the ViewModel.
Slow screen open
A trace showed three sequential network calls. Fix: run them in parallel with async and show cached data first.
Memory growth
The heap dump had 12 instances of a destroyed Activity. Fix: unregister the listener held by a singleton.
Tips
- Reproduce on a mid-range physical device whenever possible.
- Keep recordings short: a few seconds around the problem.
- Compare before and after traces when you make a fix.
- Automate checks with Macrobenchmark once you've found the problem.
Frequently asked questions
Profiler or Perfetto UI?
Android Studio's system trace view uses Perfetto data. The standalone Perfetto UI offers advanced querying (SQL) and is useful for deep analysis or traces captured outside Studio.
Why are my traces different from what users see?
Debuggable builds, fast development devices, and warm caches all hide real problems. Use profileable builds on representative devices.
Method tracing slows my app down. Is that normal?
Yes. Instrumented method tracing has high overhead. Use sampling for timing, and method tracing only for call details.
Conclusion
Match the question to the tool: system traces for slowness and jank, heap dumps and allocations for memory, Network Inspector for requests, and the Power Profiler for battery. Profile profileable builds on real devices, add custom trace sections, and verify every fix.
Next step: handle the failures you find in Debugging Crashes with Logcat.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
Performance work starts with understanding how Android apps are built and how they behave at runtime. Strengthen those fundamentals and the profiling tools start to make sense.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.