Android game development and garbage collection

I am working on a game for Android and debugging it on my N1. At first, performance was patchy. Then I worked on cleaning all distributions to prevent garbage collection. This greatly improved the situation, but I still saw some garbage collections that caused very short pauses in the animation.

Pulling my hair for a while, I noticed that the process IDs that did the garbage collection (GC_FOR_MALLOC) were not my process ID. The process identifiers belonged to the Android system and android.process.acore (determined using the Android System Info application from the market). The acore process was tied to a desktop widget called a digital clock. I removed the widget and almost made it through the whole game without any pauses. There was one very short pause for the GC for the "Android system."

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

  • How does it happen that in other games sometimes there are no pauses due to the GC system process (something from a developer control)?
  • According to the first question, how can I work with another application that calls GC, which slows down my process and causes hiccups in my game?

I just feel that something is missing me, as other games do not have this problem.

thank

+5
source share
2 answers

Can you reduce the frame rate in your game? Perhaps it uses 100% of the processor, so everything that the processor consumes will make it lag behind. These devices are not as fast as your regular PC. You can also see how to reduce the processor needed to create each frame so that the frame rate is high enough to be smooth.

+3
source
 private static Bitmap GetNonTransparentBitmap(int Id) {
  // no transparency
  Drawable tmp = myContext.getResources().getDrawable(Id);

  Bitmap retval = Bitmap.createBitmap(tmp.getMinimumWidth(), tmp.getMinimumHeight(), Bitmap.Config.RGB_565);
  Canvas canvas = new Canvas(retval);
  tmp.setBounds(0, 0, tmp.getMinimumWidth(), tmp.getMinimumHeight());
  tmp.draw(canvas);
  return retval;
 }
0
source

All Articles