开发者

Garbage collection in dalvik vm

I connect my android phone to eclipse. And I see these message from Logcat. Can you please tell me what does is the difference between 'GC_EXPLICIT' and 'GC_EXTERNAL_ALLOC'? and what does "45% free" mean?

10-05 12:08:34.450: DEBUG/dalvikvm(813): GC_EXTERNAL_ALLOC fr开发者_如何学编程eed 63K, 45% free 3156K/5703K, external 4113K/4348K, paused 73ms
10-05 12:08:34.480: DEBUG/dalvikvm(101): GC_EXTERNAL_ALLOC freed 55K, 40% free 5883K/9799K, external 4911K/4913K, paused 124ms
10-05 12:08:37.120: DEBUG/dalvikvm(101): GC_EXPLICIT freed 84K, 41% free 5870K/9799K, external 5745K/6078K, paused 104ms
10-05 12:08:40.099: DEBUG/dalvikvm(493): GC_EXPLICIT freed 14K, 48% free 3782K/7175K, external 1625K/2137K, paused 75ms
10-05 12:08:45.110: DEBUG/dalvikvm(188): GC_EXPLICIT freed 57K, 54% free 3203K/6855K, external 4988K/6206K, paused 78ms
10-05 12:09:05.119: DEBUG/dalvikvm(822): GC_EXPLICIT freed 349K, 46% free 3696K/6727K, external 1625K/2137K, paused 65ms


I would highly suggest giving the Memory Management video presentation from Google I/O 2011 a watch:

http://www.youtube.com/watch?v=_CruQY55HOk

At about 14 minutes in, he goes in to depth on exactly what these mean in the logcat output.

GC Explicit basically means that an app has explicitly called System.gc();

GC Concurrent is triggered when your heap starts to fill up and a Concurrent GC kicks in to hopefully clear memory before it fills up.


GC_EXPLICIT means your app has explicitly called System.gc() or the Activity Manger of Android System called System.gc()

GC_EXTERNAL_ALLOC is something more complicated. There are some memory related to the life time of Java's object called EXTERNAL memory. Such as memory use by GPU or pixmap resources of your app. This type of memory allocating use "malloc" of stdlib to allocation heap memory but NOT allocating from the GC Heap of Dalvik, but it's also one of the "HEAP" memory. And the total size use of the HEAP must be smaller than a limit(decide by GC).

Dalvik tracking allocation of that memory.

CONDITION: usableof(GC_HEAP) + usableof(NATIVE_HEAP[external]) <= allocaionLimit

Dalvik will cause a GC for GC_EXTERNAL_ALLOC as a sideeffect when the condition above is not true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜