Game Development Community

pooling concept

by Isaac Barbosa · in Torque Game Builder · 08/08/2009 (5:03 pm) · 5 replies

Hi,

I´ve read something about pooling when creating and destroying objects on a regular basis, but I can´t understand the concept. So, will somebody be able to explain me this, how it works, and how will it affect my games?

Thanks,
Isaac

#1
08/08/2009 (5:56 pm)
Pooling is basically just re-using objects. Say for example, you are always creating and destroying a certain kind of object, and the process is expensive. One example of "pooling" the object is, instead of destroying the object, you stick it into a queue. Then next time you need to create one, first you look into the queue to see if you have any just hanging around - if so, you just pull it out of the queue instead of creating it. The Queue in this case would be the "pool". Depending on your application, you may want to precreate your objects, and stick them in a pool so you don't have any overhead while things are running.

A good example of pooling is "Connection Pooling" and "Thread Pooling" in the .Net framework.
#2
08/08/2009 (5:57 pm)
what I´m doing is create objects and add to their proper SimSet, but when I need to delete them, I first remove them from the SimSet their belongs to and then I delete them using safedelete. I´m doing pooling without being aware of?

#3
08/08/2009 (5:59 pm)
Ah, Thanks Jaimi, now I understand. I think it will not be easy to do in my current game (that is now done) but I will try to see if that have some effect in saving memory.

The direct question is: will pooling save memory?

Take care

Isaac
#4
08/08/2009 (8:01 pm)
@Isaac -

Pooling doesn't save memory. It does however give you a speed boost in many instances. And as you suspected, the example you gave is not pooling.

Jaimi
#5
08/10/2009 (9:27 am)
@Jaimi,

Thanks, now it is clear to me.

Isaac