Game Development Community

Emiter node memory leak, need help.

by Torbjorn Leksell · in Torque Game Engine · 01/22/2006 (1:30 pm) · 3 replies

I've implemented a system where every bullet impact spawns a particle emitter, the purpose is to add a small, controlled puff of dust that emit at a fixed angle relatively to the surface the bullet hit. This works fine except the fact that every emitter node spawned stays after the emitter is done emitting particles. This in turn means that every emitter node added will pile up. The more bullets I fire, the bigger the drop in fps.

If you look at ghostable objects you see an increase of one, every time a bullet hits a surface. I've spent the whole day trying to fix this but I can't find any solution that seems to work properly. Does anyone have a fix for this?

Here you have the code that spawns the emitter:

%emitter1 = new ParticleEmitterNode(){
           dataBlock = "standard_emitter_node";
           emitter   = %emitter_1_Db;
           position  = %pos;
           surfaceNormal = %ejectionVector;
   };
   MissionCleanup.add(%emitter1);

#1
01/22/2006 (1:45 pm)
You need to set a lifetime in the creation of the emitter.
#2
01/22/2006 (2:45 pm)
@Stephen: Thanks for the quick reply, but I'm afraid I don't understand what you mean. The emitter itself stops emitting particles and the "puff" effect works fine. The problem is that the node somehow still remains active after the emitter stopped emitting particles. As far as I understand you can't set the lifetime of either the particleEmitterNodeData or the particleEmitterNode?
#3
01/24/2006 (11:58 am)
I managed to fix it myself. I Just had to add so that the emitter nodes were deleted with the particle emitters.