page.title=Heap Viewer Walkthrough
meta.tags="android, performance, profiling, tools, memory, memoryleaks, memoryheap"
page.tags="android", "performance", "profiling", "tools", "memory", "memoryleaks", "memoryheap"
page.metaDescription=Report in real-time how many objects of what types and sizes your application is allocating and find memory leaks.
page.image=tools/performance/thumbnails/tools_heap_viewer.png
page.article=true
@jd:body
In this document
You should also read
This walkthrough shows the basic usage and workflow for the Heap Viewer tool. Heap Viewer
reports in real-time what types of objects your application has allocated, how many, and
their sizes on the heap.
What it's good for:
- Getting a sense of how your app allocates and frees memory.
- Identifying memory leaks.
Prerequisites
Working with Heap Viewer
- Connect your mobile device to your computer.
- Open your application in Android Studio, build the source, and run it on your device.
- Start the Android Device Monitor from Android Studio: Tools -> Android -> Android
Device Monitor.
- Make sure your device and application are showing in the Devices tab.
- Click the DDMS button, because the Heap Viewer is one of the DDMS tools.
- Click the Heap tab, which is where your data will appear.
- In the Devices tab, select the app you want to monitor.
- To start monitoring, click the Update Heap button, which looks like a green can.
- Note the Heap updates will happen
after every GC for this client. message.
- Press the Cause CG button to
trigger a garbage collection event.
- Click a data type to see detailed information on its current allocations on the
heap.
Note: To visualize allocation changes over time, combine
several snapshots of the bar graph into an animated gif or video.