• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Memory Leak with persistent rooms

HayManMarc

Member
I was checking for memory leaks in my latest project when I noticed that simply switching rooms increased the memory usage. I'm about to create a test project and I'll post the results when I'm done.

----builds test project----

Yep, same numbers in the test project.

I would appreciate it if a few others would test this test project I made: http://haymanquarterly.com/GMC/Mem_Leak_Room_Switch_Test.zip

The test project is made with GMS2 v2.2.1.375 Runtime v2.2.1.291. It is just two rooms, one object, and one sprite. room0 is a persistent room. room1 is not persistent. The object is in both rooms and switches rooms per keyboard_check_pressed. Space bar is used to switch rooms.

When you switch from room 0 to room 1 (from a persistent room to a non-persistent room) there is no increase (however, the debugger shows a slight increase). But going the other way from room 1 to room 0 (a non-persistent room to a persistent room), there is a 152k increase to memory.

I checked it with both rooms NOT persistent resulting with no more memory increase.
I tried it with both rooms persistent and the 152k increase was with every room change.
It would seem that persistent rooms have a memory leak when you are switching to them.

I'm using the Windows Task Manager to see the memory increase. The GMS debugger is showing the increase as well, but with slightly different numbers.

Am I correct calling this a memory leak? Or is it normal for games to consume a small amount of memory while being played?
 
P

ph101

Guest
You could consider filing a bug so it's fixed, as what you describe sounds like a leak, although I havent checked your project.

edit might want to check a new object is not being made every time you start room0 tho
 

HayManMarc

Member
Thanks, but I'd like more opinions before filing a bug report.

Hopefully a few people can spare a few minutes to test this on their system.
 

TheSpydog

Member
I tried the project and got the same result. Memory only increased when switching from room 1 to room 0, and by approximately the same amount that you saw.
 

Coded Games

Member
Yep, this is a known bug, from what I found it has been around for a long time. My recommendation is to simply avoid persistent rooms altogether. In MacOS simply switching to a persistent room has like a 10% chance to randomly crash the entire runner. I recently spent quite a while expanding my games save system so that I didn't have to deal with persistent rooms. Once I got that up and running it fixed the memory leaks and random crashes.
 

HayManMarc

Member
Yep, this is a known bug, from what I found it has been around for a long time. My recommendation is to simply avoid persistent rooms altogether. In MacOS simply switching to a persistent room has like a 10% chance to randomly crash the entire runner. I recently spent quite a while expanding my games save system so that I didn't have to deal with persistent rooms. Once I got that up and running it fixed the memory leaks and random crashes.
No kidding? You'd think if this is a known bug it would be at the top of their fix-it list. Seems like a pretty important thing.
 
S

Sam (Deleted User)

Guest
I know of a software that is about to implement persistent rooms, and I'll be sure to pass this news along to that community so that they have it in their favor to not make the same mistakes.
 
Top