Trying to understand Dalvikvm and memory leaks

2019-08-07 00:10发布

问题:

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:

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.

!

Suspect 2 Dominator Tree

回答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.