lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


As you've noted any straight 'reference count strategy' can lead to thrash in this instance.
 
one simple solution would be to potentially load a resource as a 'sticky' resource, which always
exists even if no reference is present.
 
another, way which is more elegant, is to setup your objects as recyclable.
 
for instance, though your bullets are only seen somtimes, you keep them in a 'recycler', when you need one
a 'free' one is given to you, if no free ones exist one is added and given. when the object is 'done' you release it back to the free list. this means you will also avoid general new/delete thrash, and since the objects which reference the images
never die until the program ends, the images wont either.
 
-Raymond Jacobs
Owner,
Ethereal Darkness Interactive

 
On 5/11/06, Jose Marin <jose_marin2@yahoo.com.br> wrote:
Hi.

My game will have many dynamic objects (actors,
bullets, explosions, etc).

Most of them will be created during the game, have a
short life and is deleted.

What's the best strategy when you have many objects
that will be created/destroyed during the game?

I would like to avoid memory trashing.










_______________________________________________________
Yahoo! doce lar. Faça do Yahoo! sua homepage.
http://br.yahoo.com/homepageset.html