Game Development Community

Object pooling

by Craig Fortune · in iTorque 2D · 05/12/2009 (8:23 am) · 2 replies

I'm on a bit of a mission for getting the most out of iTGB in regards to speed at the moment. Specifically targeting issues I come across while developing my game.

On this front I'm pondering over doing a little work on object pooling. I had a little look around to see what people have already done in regards to this with TGB and it seems these are the interesting posts:

www.garagegames.com/search?q=object+pool&x=0&y=0 (Top 2 posts)

and for a very nice scientific viewpoint...

www.garagegames.com/community/blogs/view/15758

It is apparent to me that although the gains are pretty good in places, the data is only for a large amount of objects (starting at 610 runners, each runner being several objects). My issue is the desire to have individual objects being created promptly rather than many objects created quickly (there is a difference... honest!). So on this standpoint I want to know if anyone has done anything similar to this on iTGB and has any data to share?

Also, does anyone have any information (opinion/fact) on how expensive object creation actually is within Torque? I see a lot of conjecture on the net about this topic (in a broader sense than just Torque) and I'm not really sure what to believe :D

#1
05/12/2009 (9:15 am)
I've heard that adding objects to the scene graph dynamically is expensive so I've completely avoided it, so far, by having all my objects created during startup and reused during the level. However I haven't added the objects that will require run time creation and will be interested in seeing any results of your research on pooling support. I intend to create an object pool for dynamic sprites and add to it as needed until I receive a low memory alert, and then cut the pool size in half on every low memory alert.

#2
05/12/2009 (9:20 am)
The second link was very interesting about removing the objects from the scene graph when their not visible. I'm going to have to remember to do that, I'm not doing that right now for the objects I'm reusing, however the current reusable objects are low in count and are frequently used so I'll probably keep it that way for now. However when I start adding items that are highly dynamic and large in count I'll be sure to remember that.