[solved] Memory leak in ParticleEffect

There seems to be a memory leak in the creation of ParticleEffect(). Not sure where, however, since I’m not adept in c/c++ code, but this can easily be tested by running the particle system demo and rapidly press 1-4 plenty of times until the application starts slowing down. This is rather unfortunate for my game, which utilizes particleEffect for death of enemies.

This appears to be bug in Tut-Steam-Example.py; it never calls cleanup() on its ParticleEffect when it reloads a new effect. Replace the method:

    def loadParticleConfig(self,file):
        #Start of the code from steam.ptf
        self.p.loadConfig(Filename(file))
        #Sets particles to birth relative to the teapot, but to render at toplevel
        self.p.start(self.t)
        self.p.setPos(3.000, 0.000, 2.250)

With:

   def loadParticleConfig(self,file):
        #Start of the code from steam.ptf
        self.p.cleanup()
        self.p = ParticleEffect()
        self.p.loadConfig(Filename(file))
        #Sets particles to birth relative to the teapot, but to render at toplevel
        self.p.start(self.t)
        self.p.setPos(3.000, 0.000, 2.250)

to solve this problem.

David

oh i was the last one to touch that tut, ill fix it when i get home

Ah okay, thanks guys! :slight_smile:

Fixed it, tagged for 1.5.4.