I followed the super platformer tutorial with the gun and I was adding onto it myself. When I shoot continually for about a minute or 2, the game runs slow and the memory usage is pretty high.
I'm using a decent amount of particles for a tracer effect and for when the bullets hit something so maybe there's an issue there. Also I think I'm deleting any bullets that don't hit anything, but I'm not 100% sure.
#Memory keeps rising
16 messages · Page 1 of 1 (latest)
ok so confirm
is the memory usage high from the get go, or does it slowly creep up over time?
if you don't shoot, it is ok?
and then showing any shoot code and bullet code would be good
bullets aren't the only things that need deleting, so would be nice to see what you have so far
there it is: part_system_create in step
With this function you can destroy a given particles system and remove it from memory. This should always be called when the system is no longer needed, like at the end of a room, or in the destroy event of an instance, otherwise you could end up with particles appearing in later rooms and no way to remove them as well as a memory leak which will eventually crash your game.
Arguments
ind: The index of the particle system to destroy.
^ every time you have a destroy function, you need to use it
and that implies that that kind of data doesn't automatically get cleaned up
you have part_system_create stored in a local variable
the local variable gets cleared every step, but not the part_system. it sits in memory forever inaccessible, and since a new one is made every frame, it accumulates - this is called a memory leak
so
put all your part_system_create, part_type_create etc stuff in the create event, in an instance variable
only this needs to be in step
and then call part_system_destroy in clean up
likewise the stuff in begin step is dodgy