Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Game Development and Garbage Collection

I have a been working on a game for Android and debugging it on my N1. The performance was patchy at first. I then worked on cleaning up all allocations to prevent garbage collection. This greatly improved things, but I still saw some garbage collections occurring that caused very brief pauses in the animation.

After pulling my hair out for a while, I then noticed the process IDs that were doing garbage collection (GC_FOR_MALLOC) were not my process id. The Process Ids belonged to "Android System" and android.process.acore (determined by using "Android System Info" app from the market). The acore process was tied to a desktop widget called digital clock. I uninstalled the widget and nearly made it through the entire game without any pauses. There was one very brief pause for GC for "Android System".

Sorry for the long explanation, but now for my questions:

  1. How is it that other games don't occasionally have pauses due to the system process's GC (something out of the developer's control)?
  2. Along the lines of the first question, how can I deal with a different application causing GC that slows my process down and causes hiccups in my game?

I just feel like there is something I am missing since other games don't have this problem.

Thanks

like image 243
Steve0212 Avatar asked Oct 24 '22 22:10

Steve0212


1 Answers

Can you decrease the frame rate of your game? Maybe it's using 100% of the CPU so anything else that consumes CPU is going to make it lag. These devices are not nearly as fast as your average PC. You could also look at reducing the CPU required to create each frame in order to keep the frame rate high enough to be smooth.

like image 141
JOTN Avatar answered Dec 09 '22 04:12

JOTN