My Android game has sudden lag spikes sometimes. I know this is due to something going wrong. My phone has a 1GHz processor so there shouldn't be a problem. Basically I use the Canvas
class to render my entire game (I am about to learn OpenGL and don't know if this is the cause). I have a main game loop and about 4 threads. Why does it lag?
Thanks in advance.
Answer
This is most presumably the garbage collector kicking in.
There is no clean way to solve this problem unless you are willing to ditch Java for another language such as C++. See How can I avoid garbage collection delays in Java games? (Best Practices) for a few hints on how to mitigate the problem.
No comments:
Post a Comment