• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [SOLVED] Memory Leaks and Programs?

Neptune

Member
If a software has memory leaks (say 5 lists that dont get destroyed or something), and then it gets closed -- does this fix/purge any leakage problems?
Then running the software is a clean slate, until the leaks were to execute in the code again?

Any info is welcome!
 

O.Stogden

Member
In my experience when the program closes, it usually disappears from Task Manager (Windows). So when the program is shut the leak shouldn't affect anything. It will just cause the applications RAM usage to build up over-time whilst the application is running.

You can always check task manager to make sure there's no trace of your game running after you close it if you want to make sure this is true in your case.

Alternatively, and perhaps for the best, just make sure you track down what data structures aren't being deleted and make sure they are when the game ends. And do a check if the data structure already exists before you make it again.
 

Neptune

Member
Hey thanks for reply.
So if there was a leak, it builds up while the program is running -- but in general case, closing and restarting the software would be freeing/purging that "built up ram"...
Meaning the software would never crash, so long as the leak was not significant enough to crash in one run?
 

O.Stogden

Member
Correct.

If your app used 50MB of RAM at boot, and after an hour of use went up to 200MB due to a leak, if you closed the app and rebooted, it should be at 50MB again.
 

TheouAegis

Member
If it doesn't keep going up up up, it may not necessarily be a leak. You don't NEED to destroy data structures, sprites, buffers, whatever. It's only really a leak if your code makes them unworkable without destroying them. Simply not using it anymore isn't a leak -- it has to be "lost" to the program. You could make a data structure and bunch of sprites for every room and never destroy them, but also never go back to those rooms. That's not a memory leak because everything is still workable, they're just not being used. If you then send the player back to the main menu, let them start over, and don't verify the resources exist before creating them again, that's a memory leak and one you should not just shrug off because it's "not significant enough". It's not significant on your test runs, but you can't say with absolute certainty that no one else will run your program in such a way that it will become significant enough to crash. Treat all leaks as game-breaking, because someone will come along and break it. I've played GM games that I really liked until I broke them.
 

Neptune

Member
I see what you mean. I'm pretty careful, however I did a global search of my "creates" and "destroys", and somewhere there may be 1 or 2 mistakes. Problem is there are over 600 of each xD

If they were game breaking, surely I'd have found them, but...
I may just have to go through them all :S
 

TheouAegis

Member
You could have just overwritten a variable and not realized it. Or you have a data structure with a similar name as a resource or another variable and accidentally targeted that resource/other-variable which just coincidentally contain a valid ID so as not to cause any errors but also not destroy a data structure. That's why I personally create all my data structures and resources in one place and then just recycle them as needed.
 
Top