Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

Heap Viewer walkthrough

This tool was removed in Android Studio 3.0.

You should get the latest version of Android Studio and use the new Memory Profiler instead.

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.


Working with Heap Viewer

    1. Figure 1. Starting Memory Monitor.

    2. Connect your mobile device to your computer.
    3. Open your application in Android Studio, build the source, and run it on your device or emulator.
    4. Start the Android Device Monitor from Android Studio: Tools -> Android -> Android Device Monitor.

      Alternatively, you could start the Memory Monitor in Android Monitor.

    1. Figure 2. Steps for Using Heap Viewer.

    2. In the device and application drop-downs, select the app you want to monitor.

    1. Figure 3. Update Heap button.

    2. To save a heap dump, click the Dump Java Heap icon. The heap snapshot file with the filename appears in the Captures tab.

    1. Figure 4. Triggering GC (Garbage Collection).

    2. Note the Heap updates will happen after every GC for this client. message.
    3. Click the Initiate GC icon to trigger a garbage collection event.

    1. Figure 5. Example Heap Viewer output.

    2. Double-click the heap snapshot file to open the heap viewer and see detailed information about the current allocations on the heap.