1

I am trying to wrap my head around finding memory leaks. I suppose the first step is to see if i have one by looking at the dalvikvm but i am not really understanding whether it is good or bad. Here is a snap shot of my dalvikvm log: enter image description here

could someone just speak a bit to what is seen above. What are red flags? what is normal?

In addition, i have installed MAT for eclipse and while there are many links to tutorials about using MAT to find memory links, none of them seem to really explain how they find the leaks

can anyone point to a Detail tutorial for MAT.. below are some screen shots from my MAT Leak Suspects report.. I don't know what to make of it. If someone could talk me through the screen shots it would be much appreciated.

leak suspects!

Suspect 2 Dominator Tree suspect 2 dominator tree

erik
  • 4,946
  • 13
  • 70
  • 120
  • Why are you looking for leaks in the first place? How familiar are you with heap allocation and garbage collection? – fadden May 05 '14 at 14:37
  • I have experienced a out of memory error once... has not happened since but thought it would be good to know – erik May 05 '14 at 14:57
  • Are there any tools for getting the runtime leak information such as HotSpot JVM Gchisto – QJGui May 05 '14 at 15:20
  • The canonical "memory usage on Android" Q&A is http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android – fadden May 05 '14 at 16:41

1 Answers1

1

As the hprof's result(MAT), the largest memory used by the android app is graphics/bitmaps. This is the common situation in Android apps. You can use Android Heap profile to track the memory allocation.

Here you can use showmap to see the detail of Android app memory usage in native or java-heap.

And the way to find the memory leak is to use procrank/ps seeing the PSS/USS trend. If the trend is always increasing, there may be memory leaks. And then, you can use MAT to compare hprof for increasing java-heap.

QJGui
  • 907
  • 8
  • 10
  • you lost me at procrank/ps.. whats that? – erik May 05 '14 at 14:59
  • @erik, `procrank` and `ps` is linux(In Android eng version) command line for dumping the PSS/USS in app level. – QJGui May 05 '14 at 15:00
  • is it the same as the heap dump? – erik May 05 '14 at 15:03
  • 1
    @SamusArin As I know, poor user code is the main problem for leading memory leak. And In Dalvik, the java-heap uses dlmalloc for allocing memory, this may lead more Memory fragmentation; even if you call GC, the VM may not trim the java-heap for 4K per page in Linux. So the android low ram page suggests us to alloc/free objects at same time for more continuous memory, and this looks like Generational memory management by hand. – QJGui May 05 '14 at 15:08
  • @erik, PSS contains all virtual memory usage in one linux process. There is not only dalvik-java-heap but also malloc or many other memory information. – QJGui May 05 '14 at 15:10
  • so looking at the dalvikvm log.. is there anything that raises any flags? – erik May 05 '14 at 15:12
  • @erik, I don't know whay flags mean. And there is a page for describing the dalvikvm GC log http://developer.android.com/tools/debugging/debugging-memory.html – QJGui May 05 '14 at 15:14
  • @QJGui http://stackoverflow.com/questions/23476263/types-of-memory-leaks-in-a-garbage-collected-language-running-in-virtual-machine copy your answer they're and I'll accept it. – samus May 06 '14 at 13:52