Trying libGDX android game development: Cross-breed of Pac-man, Nethack and Gauntlet. PART III
Object pooling misery In my game there were a couple of types of objects that caused a lot of garbage and resulted in playability killing GC pauses. Java has supposed to free us from memory management? In mobile games it seems to be mandatory practice. This sucks. The idea is to have an object factory, where you can ask for objects. You need to return the objects to factory after the use. The factory recycles the objects and this way decreases the need to create new objects. The code that uses these kind of object factories becomes quite messy very easily, because you need to be sure that the objects are in all cases returned back to factory. And then you are in a big trouble if you happen to return an object that you thought is not used anymore, but in fact was still referenced somewhere. The debugging is hideous. Here you can find info about the object pooling: http://highscalability.com/blog/2015/7/29/a-well-known-but-forgotten-trick-object-pooling.html First I used li