• 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!

Windows Question About Memory Leaks

S

Sabrina Stoakes

Guest
Hello!

So, I'm closing in on the final stages of my game, and I'm starting to notice that occasionally after testing it for a long time it will randomly freeze up (With music still playing.) I have all my objects set to destroy themselves on the room end event so I thought my bases were covered on that.

The only thing I can think of that could potentially cause this would be that I have my pause screen set where it deactivates all instances. My question to you all is; do deactivated instances stay in memory? I also do texture flush at the end of each level. To be honest though, I didn't get the freezing until I started adding music to the game. I figured that it's simply weighing more on memory since I have most sound effects set as uncompressed.
 

NightFrost

Member
Yes, deactivated instances naturally stay in memory, because you may need to activate them again. Otherwise deactivation would be no different from destroying. Commanding instances to destroy themselves on room end is unnecessary as that's an automatic process when you change rooms, they all get killed along with the room. You're not mentioning how you're dealing with data structures. Their destruct commands are there as because they don't get automatically scrubbed. You can figure if you have serious memory leaks by running with the debugger and watch the memory use.
 
S

Sabrina Stoakes

Guest
Yes, deactivated instances naturally stay in memory, because you may need to activate them again. Otherwise deactivation would be no different from destroying. Commanding instances to destroy themselves on room end is unnecessary as that's an automatic process when you change rooms, they all get killed along with the room. You're not mentioning how you're dealing with data structures. Their destruct commands are there as because they don't get automatically scrubbed. You can figure if you have serious memory leaks by running with the debugger and watch the memory use.
I actually didn't know that! So would keeping instances deactivated while leaving a room destroy them, or make them stay in memory? If so, then I should be able to fix that by simply reactivating them before leaving the room to go to the main menu. Also I'm not using any data structures that I know of (Not using any DS functions or anything like that. Also I'm still a bit new to the advanced side of GM so bare with me here.)
 
S

Sabrina Stoakes

Guest
If it just freezes, you sure it's not stuck in a loop? You can find that out by using debug mode and pausing it when it freezes.
Well, it's sort of weird. I know that the game is still playing in the background because I can still feel the rumble on my gamepad when I get hit. It's like the game freezes the frame, but keeps going haha.

EDIT: However, no sound effects are played, just music.
 

O.Stogden

Member
You can open task manager (CTRL+ALT+DEL) and see if your memory usage is growing high.

For a basic game, it probably would stay below 100MB. But I made a mistake and after a couple of minutes, mine was up to 500MB+, which usually means there's a problem.

When you leave a room, any deactivated instances are destroyed, even persistent ones. To keep a persistent object between rooms, it must be activated before you switch a room.

Also check the compile window in GMS while you're testing, it might tell you if it's loading a sound/music/texture group in time with when it lags.
 
S

Sabrina Stoakes

Guest
Ran it in debug. Absolutely no memory issues anywhere. Game is staying around 53mb when I check it in task manager. Could this potentially be an issue with my GPU? I had a strange issues earlier with flashing that I confirmed was only happening on my end and this PC is getting older...
 

matharoo

manualman
GameMaker Dev.
Ran it in debug. Absolutely no memory issues anywhere. Game is staying around 53mb when I check it in task manager. Could this potentially be an issue with my GPU? I had a strange issues earlier with flashing that I confirmed was only happening on my end and this PC is getting older...
Did you pause the debug window when the game froze, to see what code the game was at?
 
S

Sabrina Stoakes

Guest
Did you pause the debug window when the game froze, to see what code the game was at?
I couldn't get it to freeze in windowed mode, but it did freeze in fullscreen, and then unfroze when I alt+tabbed to windowed again... sooooo hmmmmm LOL
 
S

Sabrina Stoakes

Guest
Now that's weird, not something that would happen with loops (in most cases)
Yeah I'm chalking this one up to my PC. I've been testing it for almost an hour in windowed mode and haven't had a single freeze up. The memory usage has actually dropped a little too.
 

NightFrost

Member
I actually didn't know that! So would keeping instances deactivated while leaving a room destroy them, or make them stay in memory? If so, then I should be able to fix that by simply reactivating them before leaving the room to go to the main menu. Also I'm not using any data structures that I know of (Not using any DS functions or anything like that. Also I'm still a bit new to the advanced side of GM so bare with me here.)
Activation state doesn't matter there; when a room gets flushed, everything that has been instanced into it also gets flushed. Exceptions are, of course, instances created from persistent objects, and rooms that have been set persistent.
 
Top