Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android game programming - Heap issues

I work for a small Android game development company, and currently I'm having an issue. I'm running a pretty standard windows 7 x64 machine, with Eclipse and the Android SDK.

I was reading the LogCat output for my program, wondering why my game wouldn't even show up. I quickly saw all of the heap growing, and thought I may have too many textures/too big of textures, etc. I pinpointed the problem to texture loading, then I started using DDMS and noticed my heap won't grow above 19MB. I cut out a couple textures and tried to build and run again. To my shock, the heap wouldn't grow past 6.6MB, consistently. Does anyone have any suggestions?

tl;dr: My heap was growing to 19MB then failing, so I took out textures that were more memory-expensive to keep it under 19MB in the heap, and now my heap won't grow past 6.6MB.

EDIT: logcat ouput when bigger textures are taken out:

08-19 19:19:53.744: DEBUG/dalvikvm(4699): GC_FOR_MALLOC freed 91 objects / 514016 bytes in 49ms
08-19 19:19:54.184: DEBUG/dalvikvm(4699): GC_FOR_MALLOC freed 104 objects / 494088 bytes in 48ms
08-19 19:19:54.404: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
08-19 19:19:54.764: DEBUG/dalvikvm(4699): GC_FOR_MALLOC freed 85 objects / 384664 bytes in 49ms
08-19 19:19:54.935: WARN/ActivityManager(59): Activity idle timeout for HistoryRecord{4612eec8 com.wickeyware.zombiearcher.android/.AndroidGame}
08-19 19:19:55.234: DEBUG/dalvikvm(4699): GC_FOR_MALLOC freed 104 objects / 504648 bytes in 47ms
08-19 19:19:55.875: DEBUG/dalvikvm(4699): GC_FOR_MALLOC freed 85 objects / 505712 bytes in 55ms
08-19 19:19:56.905: DEBUG/dalvikvm(4699): GC_FOR_MALLOC freed 104 objects / 522392 bytes in 50ms
08-19 19:19:57.535: DEBUG/dalvikvm(4699): GC_FOR_MALLOC freed 56 objects / 388896 bytes in 50ms
08-19 19:19:57.695: INFO/WindowManager(59): WIN DEATH: Window{4606a8a0 com.android.launcher/com.android.launcher2.Launcher paused=false}
08-19 19:19:57.705: INFO/ActivityManager(59): Process com.android.launcher (pid 4669) has died.
08-19 19:19:57.825: INFO/ActivityManager(59): Low Memory: No more background processes.
08-19 19:19:57.865: INFO/dalvikvm(4699): dvmDdmHandleHpsgChunk(when 1, what 0, heap 0)
08-19 19:19:58.575: DEBUG/ddm-heap(4699): Heap GC request
08-19 19:19:58.685: DEBUG/dalvikvm(4699): GC_EXPLICIT freed 48 objects / 313440 bytes in 106ms
08-19 19:20:01.015: INFO/ActivityManager(59): Process jp.co.omronsoft.openwnn (pid 4677) has died.
08-19 19:20:01.095: WARN/ActivityManager(59): Scheduling restart of crashed service jp.co.omronsoft.openwnn/.OpenWnnJAJP in 5000ms
08-19 19:20:01.106: INFO/ActivityManager(59): Low Memory: No more background processes.
08-19 19:20:03.105: INFO/ActivityManager(59): Process com.wickeyware.zombiearcher.android (pid 4699) has died.
08-19 19:20:03.155: INFO/WindowManager(59): WIN DEATH: Window{46138b68 SurfaceView paused=false}
08-19 19:20:03.275: INFO/WindowManager(59): WIN DEATH: Window{4612d530 com.wickeyware.zombiearcher.android/com.wickeyware.zombiearcher.android.AndroidGame paused=false}
08-19 19:20:03.425: INFO/ActivityManager(59): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=4710 uid=10025 gids={}
08-19 19:20:03.425: INFO/ActivityManager(59): Low Memory: No more background processes.
08-19 19:20:03.775: INFO/UsageStats(59): Unexpected resume of com.android.launcher while already resumed in com.wickeyware.zombiearcher.android
08-19 19:20:03.904: INFO/ActivityThread(4710): Publishing provider com.android.launcher2.settings: com.android.launcher2.LauncherProvider
08-19 19:20:04.005: DEBUG/dalvikvm(4710): GC_EXTERNAL_ALLOC freed 985 objects / 73440 bytes in 58ms
08-19 19:20:04.465: WARN/InputManagerService(59): Got RemoteException sending setActive(false) notification to pid 4699 uid 10036
08-19 19:20:04.984: INFO/ActivityManager(59): Displayed activity com.android.launcher/com.android.launcher2.Launcher: 1703 ms (total 20584 ms)
08-19 19:20:06.124: INFO/ActivityManager(59): Start proc jp.co.omronsoft.openwnn for service jp.co.omronsoft.openwnn/.OpenWnnJAJP: pid=4718 uid=10023 gids={}
like image 661
Evan Avatar asked Aug 19 '11 17:08

Evan


1 Answers

GC_FOR_MALLOC freed 104 objects / 504648 bytes in 47ms

This is the garbage collector firing. Unfortunatly, without any source, nobody here will be able to help you.

But, it looks like you are instantiating WAY too many objects and the garbage collector is almost constantly firing.

like image 147
edthethird Avatar answered Nov 12 '22 18:11

edthethird