What Do Gc_For_Malloc, Gc_Explicit, and Other Gc_* Mean in Android Logcat

What do GC_FOR_MALLOC, GC_EXPLICIT, and other GC_* mean in Android Logcat?

GC_FOR_MALLOC means that the GC was triggered because there wasn't enough memory left on the heap to perform an allocation. Might be triggered when new objects are being created.

GC_EXPLICIT means that the garbage collector has been explicitly asked to collect, instead of being triggered by high water marks in the heap. Happens all over the place, but most likely when a thread is being killed or when a binder communication is taken down.

There are a few others as well:

GC_CONCURRENT Triggered when the heap has reached a certain amount of objects to collect.

GC_EXTERNAL_ALLOC means that the the VM is trying to reduce the amount of memory used for collectable objects, to make room for more non-collectable.

Update: There has been a name-change of the first event in later versions of Android. It's now called "GC_FOR_ALLOC".
There is also a new event available, although very rare in modern phones:
GC_BEFORE_OOM means that the system is running really low on memory, and that there is a final GC performed, in order to avoid calling the low memory killer.

the log of GC on Android

In this Google IO I once watched I believe the presenter (Patrick Dubroy) states the different logs, and their association: Google I/O: Memory Management for Android Apps

I hope this helps.

When I Syn between sql server & sqlite I got this error GC_FOR_MALLOC

Hmm, GC is usually only performed when there is a need for it. Try debugging the code to see what might be using so much memory. There must not be enough memory left on the heap to perform an allocation.

Curious, are you using sockets for this type of application? I have heard where a front-end application written on Android in Java connects through a socket to a back-end server (not a "Service", in Android terms) written in C. During stress-testing, the server was killed to see how the app would react. When this happened, the device would flood the log with this kind of error. This was because there was a separate thread which ran once it connected, and it would send a request for data, expecting to receive something back from a server that was no longer there.

Perhaps your application or web server believes it is still connected, has a process running that is trying to send/receive data, or something similar.

Can too many GC affect decrease significatly the device battery?

GC is an expensive operation, then I think you should care about those many log messages.

See Managing Bitmap memory to check Android's tips.

See also this answer to understand GC log messages.

GC_FOR_MALLOC means that the GC was triggered because there wasn't enough memory left on the heap to perform an allocation. Might be triggered when new objects are being created.

GC_EXPLICIT means that the garbage collector has been explicitly asked to collect, instead of being triggered by high water marks in the heap. Happens all over the place, but most likely when a thread is being killed or when a binder communication is taken down.

There are a few others as well:

GC_CONCURRENT Triggered when the heap has reached a certain amount of objects to collect.

GC_EXTERNAL_ALLOC means that the the VM is trying to reduce the amount of memory used for collectable objects, to make room for more non-collectable.

Update: There has been a name-change of the first event in later versions of Android. It's now called "GC_FOR_ALLOC". There is also a new event available, although very rare in modern phones: GC_BEFORE_OOM means that the system is running really low on memory, and that there is a final GC performed, in order to avoid calling the low memory killer.



Related Topics



Leave a reply



Submit