Home Tags Archive
+ TWITTER Add to Google
Recent Articles

Interpreting GC log messages

Authors : luigi agosti - Date : 30/10/2011 - Views : 4295
This is a very nice talk about memory management for android applications. From it I got a few important points to keep in mind. In particular I like to mark the part relative to GC logs.
GC logs, how to read them
Anytime that there is a gc you see a message like this :
D/dalvikvm (10293): GC_CONCURRENT freed 831K, 48% free 3831K/7239K, external 1625K/2137K, paused 2ms+2ms

//[Reason] [Amount Freed], [Heap Statistics], [External Memory Statistics], [Pause Time]

The first bit "GC_CONCURRENT" is the reason why the gc started. Reasons are :
GC_CONCURRENT is triggered when there is a need to free up memory. In this way it is releasing memory before there is a real need to pause and call the gc.
GC_EXPLICIT : triggered by a call to System.gc().
GC_HPROF_DUMP_HEAP : if you dumb the heap.
GC_FOR_MALLOC : this is triggered when the heap is full and we have to stop and wait for the gc to free the heap.
GC_EXTERNAL_ALLOC : means that the VM is trying to reduce the amount of memory used collectable objects, to make room for non-collectable object such as bitmap, nio direct by buffer (not there in honeycomb).
Amount Freed
Amount of memory release during the gc operation.
Heap Statistics
48% free 3831K/7239K : The percentage indicates the memory free after the gc operation. The first number 3831 is the current heap, while the second 7239k indicates the total heap size.
External Memory Statistics
Before honeycomb the external memory was used by bitmaps and file operation with nio buffers.
Pause Time
It is the time that was necessary to perform the gc operation. It is important to notice that the difference between a concurrent gc and a non-concurrent is more then a magnitude. Usually concurrent gc are 2ms+2ms while non concurrent gc events are greater than 80ms