java - Vastly Overzealous GC on Android -


i'm developing game android, , having huge (and unpredictable) issues garbage collector.

during 1 phase of loading, allocate 18,000 1616 byte arrays (some chunked level data). sometimes, not always, garbage collector decide run sweep after every single allocation, increasing heap size:

06-13 13:51:59.362  16941-17640/com.lp.aeronautical.android d/dalvikvm﹕ gc_for_alloc freed 0k, 17% free 41923k/50472k, paused 191ms, total 191ms 06-13 13:51:59.362  16941-17640/com.lp.aeronautical.android i/dalvikvm-heap﹕ grow heap (frag case) 43.037mb 1616-byte allocation 06-13 13:51:59.536  16941-17640/com.lp.aeronautical.android d/dalvikvm﹕ gc_for_alloc freed 0k, 17% free 41926k/50476k, paused 174ms, total 174ms 06-13 13:51:59.536  16941-17640/com.lp.aeronautical.android i/dalvikvm-heap﹕ grow heap (frag case) 43.040mb 1616-byte allocation 06-13 13:51:59.765  16941-17640/com.lp.aeronautical.android d/dalvikvm﹕ gc_for_alloc freed 0k, 17% free 41931k/50480k, paused 179ms, total 179ms 

repeated 18,000 allocations. needless horrid , makes game chug badly few minutes.

is there way reel in gc on android? or perhaps @ least make grow heap in larger chunks? (which fine).

i ended converting of array allocations bytebuffers allocated bytebuffer.allocatedirect. meant making 18000 small java heap allocations (just pointers basically), , of array memory stored in native memory.

moving big allocations native memory meant dalvik gc no longer noticed allocations problem.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -