the log of GC on Android - android

i face a problem on understand the GC log.
Log: GC_EXTERNAL_ALLOC freed 82K, 48% free 2829K/5379K, external 1702K/2137K, paused 28ms
Anyone can explain the meaning of the log?
Thanks.

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.

I don't think those log messages are documented.
If you're developing with Eclipse you are supposed to use DDMS perspective | Allocation Tracker to track your memory allocations.

Related

android - GC_FOR_ALLOC freed 6346K, 7% free , paused 143ms, total 143ms

I'm developing an offline mapView using OSMdroid Library. My tilesource loads the tiles but renders quit steadily. But the fact is in my log messages, I keep getting this error:
GC_FOR_ALLOC freed 6346K, 7% free , paused 143ms, total 143ms
I'm not sure how to debug this? Any ideas, do I have any memory leaks?
This is not an error, but an information that Garbage collector has run.
If you are seeing a lot of those, it might mean that you are making many allocations or have little memory. You should try to improve your program's memory performance.
There is a good source information about investigating RAM consumption in Android:
https://developer.android.com/tools/debugging/debugging-memory.html
There is also a document about general strategies for managing your memory consumption in Android:
http://developer.android.com/training/articles/memory.html

Why does it always shows GC_CONCURRENT FREED and GC_CONCURRENT ALLOCATE in Android Logcat while running a app?

I would like to know that why does the below message shows up everytime while running any application.
12-11 17:18:37.141: D/dalvikvm(3155): GC_CONCURRENT freed 485K, 9% free 6696K/7303K, paused 9ms+335ms
paused 9ms+335ms due to this pause my audio which i supposed to play is missing, because as per my code it receives audio data every 40ms so here it paused for 9ms+335ms which is 10 times data loss
I know its performing some kind of Garbage Collection but my question is why does it frequently comes in the logcat.
Thanks for any kind of help!!!!!!
Garbage Collection is used by Java to prevent you from going Out of memory by removing Objects that are no longer referenced by any class and cannot be reached from your code.
If you have too many of these objects, you will get GC calls alot, which may at some times affect your performance. On the other hand, having Objects that are referenced all the time, may prevent GC from being called (memory leak) and your memory may fill up and you get an OutOfMemoryException.
Your goal is not to eliminate GC, but reduce them as much as possible in methods that are delay sensitive and are running on the UI thread (like onDraw(), getView(), ... for e.g.).
That is normal behaviour for Android. The phone just does garbage collection.
For more information checkout the great Google I/O video on this:
Google I/O 2011: Memory management for Android Apps
Folks, check out these doc/links,its related to memory management:
http://static.googleusercontent.com/media/www.google.com/en//events/io/2011/static/presofiles/memory_management_for_android_apps.pdf
http://eclipse.org/mat/
http://therockncoder.blogspot.in/2012/09/fixing-android-memory-leak.html

I want to Understand Android Log

is any one know what is the meaning this LOG test
it display every time when i do any operation in my APP
TEXT
09-06 17:41:30.194: D/dalvikvm(4900): GC_CONCURRENT freed 440K, 49% free 3317K/6471K, external 0K/512K, paused 4ms+7ms
dos it related to memory allocation ?
GC_CONCURRENT
Means that Garbage Collection happens in a parallel manner. Without affecting any performance.
freed 440K
This particular cycle of GC has freed 440k memory.
free 3317K/6471K
Available and total Heap Memory Details.
external 0K/512K
External Memory available for your app(other than heap).
4ms+7ms
4ms at the beginning of GC was paused and at the end 7ms was consumed by GC.
That is, during this GC, all your activities were suspended for a total of 11ms , 4ms at the beginning and 7ms at the end.
For more info on this, please watch this video. He explains this very clearly.
Patrick Dubroy Memory Management
Indeed. It shows that garbage colector was fired ( which happens on regular basis) and it could reclaim 440K of memory. Whether it is a lot or not depends on your application, but less is better. Rule of thumb is to avoid memory allocation whenever possible.

android: LogCat does not tell me the available/free memory

The guy in the Google IO video tells me to look at the log output from logcat to determine the available memory:
http://www.youtube.com/watch?v=_CruQY55HOk (at 28:37)
this user also pasted the logcat lines including % of free memory:
How to check memory leakage from message log in Logcat?
Unfortunately MY logcat does NOT print the percentage of free memory:
D/dalvikvm(15670): GC_EXTERNAL_ALLOC freed 594 objects / 10616 bytes in 23ms
Can someone tell me why?
The logcat messages are dependent on your device and possibly the OS version.
ex: For me, the Android 1.5 simulator showed no free memory %, but the Android 3.0 did show the free memory %.

Android logs 'GC_EXTERNAL_ALLOC' 'GC_FOR_MALLOC'

While running my apps, I have got this kind of logs:
GC_EXTERNAL_ALLOC freed 2K, 38% free 8772K/14087K, external 17480K/17998K, paused 87ms
GC_FOR_MALLOC freed 0K, 38% free 8772K/14087K, external 17480K/17998K, paused 67ms
GC_CONCURRENT freed 2125K, 47% free 6214K/11719K, external 7142K/8400K, paused 3ms+5ms
Does anyone know what these logs mean? Thanks in advance!
What is the difference between 'GC_EXTERNAL_ALLOC', 'GC_FOR_MALLOC' and 'GC_CONCURRENT'. Are there some other 'GC' events?
What does '38% free 8772K/14087K' mean? What is '8772K' and what is '14087K'?
What does 'external 17480K/17998K' mean? What is '17480K' and what is '17998K'?
Thanks!
Another place where the Dalvik garbage collector messages are explained is in this video: Google I/O 2011: Memory management for Android Apps
At about 14 minutes into the presentation, he breaks down the message format. (BTW, that video has really good info on debugging memory leaks)
Roughly speaking, the format is [Reason] [Amount Freed], [Heap Statistics], [External Memory Statistics], [Pause Time]
Reason
Viktor/Robert already explained GC_CONCURRENT, GC_FOR_MALLOC, GC_EXTERNAL_ALLOC.
There is also:
GC_HPROF_DUMP_HEAP - If you dump heap by clicking the "dump heap" button from DDMS or programatically
GC_EXPLICIT - If you call System.gc()
Amount Freed
E.g. freed 2125K
Self explanatory
Heap Statistics
E.g. 47% free 6214K/11719K
These numbers reflect conditions after the GC ran. The "47% free" and 6214K reflect the current heap usage. The 11719K represents the total heap size. From what I can tell, the heap can grow/shrink, so you will not necessarily have an OutOfMemoryError if you hit this limit.
External Memory Statistics
E.g external 7142K/8400K
Note: This might only exist in pre-Honeycomb versions of Android (pre 3.0).
Before Honeycomb, bitmaps are allocated external to your VM (e.g. Bitmap.createBitmap() allocates the bitmap externally and only allocates a few dozen bytes on your local heap). Other examples of external allocations are for java.nio.ByteBuffers.
Pause Time
If it's a concurrent GC event, there will be two times listed. One is for a pause before the GC, one is for a pause when the GC is mostly done.
E.g. paused 3ms+5ms
For non-concurrent GC events, there is only one pause time and it's typically much bigger.
E.g. paused 87ms
I was also looking for this information.
GC stands for garbage-collector, which collects unused objects during runtime of your app.
GC_EXTERNAL_ALLOC: Means that the VM is trying to reduce the amount of memory used collectable objects, to make room for non-collectable objects.
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_CONCURRENT: Triggered when the heap has reached a certain amount of objects to collect.
I am guessing that the 38% free means that 38% of the heap is unused. 8772K would be the size of the used memory on the heap and 14087K would be the size of the heap.
I donĀ“t know, sorry.
Please note that all of this information is based on a post from Robert on a similiar question posted here on stackoverflow. All credit (as long as this is correct) goes to Robert.

Categories

Resources