Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!!!!!

like image 784
G M Ramesh Avatar asked Dec 11 '12 11:12

G M Ramesh


2 Answers

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.).

like image 99
Mohamed_AbdAllah Avatar answered Sep 28 '22 05:09

Mohamed_AbdAllah


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

like image 21
Kung Foo Avatar answered Sep 28 '22 05:09

Kung Foo