r/truegamedev • • Oct 29 '14

Is object pooling worthwhile?(Java, Android)

has anyone here implemented some form of object pooling for games in java?

did you find it was worthwhile?

I attempted to make my own but i have found it's introducing a lot of complexity almost entirely due to the need to set object types. http://stackoverflow.com/questions/19883211/libgdx-object-pool-for-many-objects-of-the-same-parent-class

Having to keep all the objects as one type i decided to make them all generic entities. They then get their properties from classes i've called "EntityTypes" on single instances of these EntityTypes exist but can be shared by multiple Entities.

So the only difference between a Planet Entity and a ship Entity would be the EntityType they happen to use, and other variables which contain an object3d , position , velocity etc.

This would be easier if i could extend the pool objects.

So now im thinking of having multiple pools http://stackoverflow.com/questions/13294757/using-object-pools-in-libgdx

tl;dr is object pooling worth it in java games?

7 Upvotes

27 comments sorted by

View all comments

Show parent comment

1

u/strategosInfinitum Oct 31 '14

Your EntityType solution sounds a lot like it's trying too hard to re-create an object system in a language that already has one.

So far it's a disastrous gift that keeps on giving.

1

u/Tasgall Oct 31 '14

Hey, if it works and isn't too much of a pain to deal with, you might as well stick to it. As long as it protects you from periodic lag spikes caused by the GC it's Good Enough™ :P