ZombieSquirrel
Member
Hi everyone.
I'm currently making a weather system, with the current states:
"sunny"
"cloudy"
"rain"
"storm"
"snow"
"snowstorm"
I can get it to work and it looks beautifull, but whenever I leave the game on too long, or stay in a room for too long, the game experiences more and more lag to the point of it becoming unplayable.
My rooms are persistent.
Basically, I have an emitter for each of the weather states.
These are created in the ROOM START event. Room start and Room end should be fine right?
It's a lot of code, and I won't post it here. Basically in the ROOM START event, I create the particle system, create the particles, define the parameters of the particles, define the regions, and create the emitters.
At room start, the system, the particles,... are defined. Then in if statements, the emitters are created:
If it's sunny, no emitter is created.
If it's cloudy, only the cloud emitter.
If it's rain or storm, clouds and rain are generated at different intensities.
Same for snow, and snowstorm.
What confuses me is this: in the ROOM END and CLEANUP events, I put this code:
part_type_destroy(particleType_Rain);
part_type_destroy(particleType_Snow);
part_type_destroy(particleType_Splash);
part_type_destroy(particleType_Cloud);
part_emitter_destroy(particle_system, emitterRain);
part_emitter_destroy(particle_system, emitterStorm);
part_emitter_destroy(particle_system, emitterSnow);
part_emitter_destroy(particle_system, emitterSnowstorm);
part_emitter_destroy(particle_system, emitterCloud);
part_system_destroy(particle_system);
This should destroy everything I created in the room start event right? All the particles, all the emitters and the particle system are covered here.
I did this to prevent the memory leaks and clean up memory, so I won't have lag.
Yet somehow, it happens. After a long enough time, lag builds up and builds up,... Which leaves me to believe I didn't clean up the memory.
Any ideas on how to properly clean up to prevent lag?
I'm currently making a weather system, with the current states:
"sunny"
"cloudy"
"rain"
"storm"
"snow"
"snowstorm"
I can get it to work and it looks beautifull, but whenever I leave the game on too long, or stay in a room for too long, the game experiences more and more lag to the point of it becoming unplayable.
My rooms are persistent.
Basically, I have an emitter for each of the weather states.
These are created in the ROOM START event. Room start and Room end should be fine right?
It's a lot of code, and I won't post it here. Basically in the ROOM START event, I create the particle system, create the particles, define the parameters of the particles, define the regions, and create the emitters.
At room start, the system, the particles,... are defined. Then in if statements, the emitters are created:
If it's sunny, no emitter is created.
If it's cloudy, only the cloud emitter.
If it's rain or storm, clouds and rain are generated at different intensities.
Same for snow, and snowstorm.
What confuses me is this: in the ROOM END and CLEANUP events, I put this code:
part_type_destroy(particleType_Rain);
part_type_destroy(particleType_Snow);
part_type_destroy(particleType_Splash);
part_type_destroy(particleType_Cloud);
part_emitter_destroy(particle_system, emitterRain);
part_emitter_destroy(particle_system, emitterStorm);
part_emitter_destroy(particle_system, emitterSnow);
part_emitter_destroy(particle_system, emitterSnowstorm);
part_emitter_destroy(particle_system, emitterCloud);
part_system_destroy(particle_system);
This should destroy everything I created in the room start event right? All the particles, all the emitters and the particle system are covered here.
I did this to prevent the memory leaks and clean up memory, so I won't have lag.
Yet somehow, it happens. After a long enough time, lag builds up and builds up,... Which leaves me to believe I didn't clean up the memory.
Any ideas on how to properly clean up to prevent lag?