r/truegamedev • u/strategosInfinitum • 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?
View all comments
Show parent comment
1
u/nonotan Dec 21 '14
I don't understand what you mean. Pooling = reusing. I don't know what you could mean by "pathologically worst case" -- if you don't allocate anything whatsoever during gameplay, your GC shouldn't do anything (unless it's buggy). It sounds like a problem with your specific implementation of pooling.