Game Development Community

Particle emitters not removing correctly?

by University Of Texas 1 · in Torque Game Engine · 09/21/2004 (2:09 pm) · 8 replies

We're having problems with the projectile system and its particle emitters. We are firing high numbers of projectiles and are experiencing a growing memory footprint that does not go back down once firing has ceased. Using some static counters I've found that the particle emitters do not all appear to be self removing once they are empty. What could be causing this is a complete mystery and is becoming very frustrating. Using the built in memory dump function shows that after a couple minutes of firing by the turrets (20 turrets firing about 4 rounds a second each), the memory is by a large majority all taken by three 'new' operators in the following areas:

shapeImage.cc: 1813 -- bem->emitter = new ParticleEmitter;
projectile.cc: 472 -- ParticleEmitter* pEmitter = new ParticleEmitter;
projectile.cc: 484 -- ParticleEmitter* pEmitter = new ParticleEmitter;

I should mention that these two files are completely unmodified by our team and the only projectile changes that have been made are in script. What is even more confusing is that all the explosions that these projectiles create upon impact clean up completely (ie there are no rogue particle emitters left hanging around from the explosion). Anybody have any suggestions?

#1
09/22/2004 (5:44 am)
Maybe delete them in the explosion or projectile destructor?
#2
09/22/2004 (2:27 pm)
Well they are supposed to be getting deleted in the onRemove function of the particle emitter.
#3
09/22/2004 (3:05 pm)
You dont want to just delete the particle emitter otherwise you'll get a 'pop' from all the particles disappearing and it will look wrong.

There is a function for particle emitters called deleteWhenEmpty which will delete the emitter when the lifetime of all the particles it is currently emitting becomes zero.

There is an issue with TGE, which has been fixed in TSE, wherein particle emitters are not properly freeing memory when the application is shutdown.
#4
09/22/2004 (4:58 pm)
Yea i meant that delete when empty function instead of just simply deleting them...

what is this issue you speak of in TGE? these three particle emitters of mine are not freeing memory, which is obvious when you go thru the mem dump logs, since 95% of the entries are for those three statements. is this issue fixable in tge?
#5
09/23/2004 (8:47 am)
There is an issue in TGE wherein some emitters won't get deleted when you quit from the application immediately, via typing quit(); in the console or force closing the application.

It can also occur, but less frequently, when you exit a mission back to the main menu and then immediately quit from there, but usually in that time frame the emitters get deleted.

It's on GG's todo list eventually but if you would like to take a crack at fixing it and submit a patch that would be great.
#6
09/23/2004 (5:21 pm)
So is there an issue w/ deleteWhenEmpty??? or is it something else?

I know there was an issue w/ what Robert was saying, but I sorta thought there was a fix for that one??? Maybe something else for mission unload.

-s
#7
03/23/2006 (3:44 am)
Is deleteWhenEmpty function problem already fixed in TGE 1.3? I am facing similar issues. Any update on it will be helpful.
#8
03/23/2006 (1:28 pm)
JW,

http://www.garagegames.com/mg/forums/result.thread.php?qt=38472

There's a solution posted in that thread for explosion emitters not being cleaned up. The issue also exists in 1.4, so it will need corrected. As far as I can tell, that is the only issue w/ emitters not being cleaned up post 1.3.

Hope this helps!