Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait for concurrent GC blocked

When I run my application on emulator the Logcat is showing this:

04-22 16:21:30.685: D/dalvikvm(967): GC_CONCURRENT freed 1545K, 20% free 7019K/8720K, paused 78ms+17ms, total 360ms

04-22 16:21:30.685: D/dalvikvm(967): WAIT_FOR_CONCURRENT_GC blocked 143ms
04-22 16:21:31.845: D/dalvikvm(967): GC_CONCURRENT freed 1552K, 20% free 7019K/8720K, paused 116ms+18ms, total 554ms

04-22 16:21:31.845: D/dalvikvm(967): WAIT_FOR_CONCURRENT_GC blocked 268ms
04-22 16:21:32.435: D/dalvikvm(967): GC_CONCURRENT freed 1545K, 20% free 7019K/8720K, paused 75ms+9ms, total 192ms

04-22 16:21:32.435: D/dalvikvm(967): WAIT_FOR_CONCURRENT_GC blocked 73ms
04-22 16:21:32.945: D/dalvikvm(967): GC_CONCURRENT freed 1552K, 20% free 7019K/8720K, paused 75ms+10ms, total 209ms

04-22 16:21:32.945: D/dalvikvm(967): WAIT_FOR_CONCURRENT_GC blocked 70ms
04-22 16:21:33.434: D/dalvikvm(967): GC_CONCURRENT freed 1545K, 20% free 7019K/8720K, paused 78ms+12ms, total 192ms

and this continues until I exit the application.Any suggestion?Thanks

like image 445
melib Avatar asked Apr 22 '13 16:04

melib


4 Answers

Seems like you're creating many new objects and throw them away soon.

For WAIT_FOR_CONCURRENT_GC see this one: what does WAIT_FOR_CONCURRENT_GC blocked mean?

It means you try to allocate memory (for example object creation) and it doesn't fit into memory. Thats what GC_CONCURRENT freed is caused by. Its just usual garbage collection.

If you've got performance problems, try to reuse objects or spare them.

like image 142
luxer Avatar answered Nov 16 '22 17:11

luxer


This means you are doing too many operations and a lot of memory is being used. Hence, GC(Garbage collector) is being called to free up memory.

04-22 16:21:30.685: D/dalvikvm(967): GC_CONCURRENT freed 1545K, 20% free 7019K/8720K, paused 78ms+17ms, total 360ms

freed indicates how much memory was freed

GC_CONCURRENT Invoked when the heap gets too large to prevent overflow.

paused 78ms+17ms – indicates how much time it took the GC to finish collection.

Refer

Additionally take memory dump and analyze the dump use MAT tool.

like image 25
Sunny Kumar Aditya Avatar answered Nov 16 '22 17:11

Sunny Kumar Aditya


Agree mostly with @luxer, but I believe it's not that you are allocating too many objects, but you are allocating some huge objects. If you refer to the link pointed by @luxer about WAIT_FOR_CONCURRENT_GC, you will realize that a second gc is being triggered in your app while a concurrent gc (which is typically triggered when the heap occupancy hits a soft limit) is in progress. The second gc could have been triggered by you explicitly or because an allocation failed. Since you have not indicated that you're calling System.gc(), I would assume that your allocations are failing and the system is trying to do a gc.

So, yeah, you should seriously consider reusing some huge objects instead of allocating them each time. This is a better practice, but if for some reason you're unable to do that, you can probably bump your heap size (by setting large heap) and that may help.

like image 2
layman Avatar answered Nov 16 '22 16:11

layman


Sometimes it happens when you have a never ending loop just because some condition is always true.

Try to figure out if its this case first as it happens mostly because of this.

like image 2
My God Avatar answered Nov 16 '22 16:11

My God