Legacy GM [Solved] Avoiding Memory Leaks With Particle Systems

Pro_bono

Member
The manual recommends destroying Particle Systems when not in use as to avoid a memory leak, I gather in case different objects keep making unique systems and they pile up in memory.

I was just wondering, if I store the particle system, particle type and emitter in global variables that all objects reference, would that mean that if another object creates a new system/type/emitter assigned to the same global variables it would just be overwriting the existing data and not causing a leak?

edited for a superfluous sentence
 
Overwriting the global variables before destroying the particle systems/types/emitters they refer to will cause a memory leak.
 

Pro_bono

Member
Overwriting the global variables before destroying the particle systems/types/emitters they refer to will cause a memory leak.
Right, what is the reason for that do you know? Perhaps I'll have each instance create its own local particle systems upon creation and destroy them when either the room ends or they're destroyed, to be safe.
 
The variables store a reference to the particle system, not the particle system/data itself.

It's like your phone storing your friends phone numbers. Just because you delete a phone number from your phone, it doesn't actually destroy your friends phone. Or in your example, I could change my friends phone number in my phone to another one, but my friends phone number doesn't change, and now I can't call them anymore, even though their phone number still exists.
 

Pro_bono

Member
Right, got you. I guess theres a lot of information in a particle system, it seems silly now to think it would all be contained within one variable. I'm not a tech guy you may have noticed. :)

Thanks a lot!
 
Top