Search code examples
javaandroidmemory-managementmonitoringddms

How to see heap usage on app start up?


I'm trying to see what the memory usage to start the app is, but the only way I know to monitor the usage is through the DDMS taking snapshots. Obviously I'm not quick enough to setup and take the snapshot after the process starts. I need to graph the usage to see where it peaks. Any easy way to do this? Ideally, It would be nice to see how much of the memory usage is from each individual process. I realize this is a pretty complicated request, I just thought it was worth asking, as it would save me loads of work in trial and error. Thanks for any ideas!


Solution

  • I usually follow the steps indicated in the android doc (DDMS section), you might have already seen it:

    • In the Devices tab, select the process that you want to see the heap information for.
    • Click the Update Heap button to enable heap information for the process.
    • In the Heap tab, click Cause GC to invoke garbage collection, which enables the collection of heap data. When the operation completes, you will see a group of object types and the memory that has been allocated for each type. You can click Cause GC again to refresh the data.
    • Click on an object type in the list to see a bar graph that shows the number of objects allocated for a particular memory size in bytes.

    Anyway I hope it will help a bit!