Efficiency and Pinwheeling

Hi

The longer I play my game, the longer it takes to load the next room. Does anybody have any suggestions or guides on ways to make GMS2 use less resources, not leak memory, and just speed it up in general. I'm using texture groups but that's the only way I really know how to speed things up. About halfway through a play through of the game my Mac starts pinwheeling for a few seconds when switching rooms.

-TW
 

CloseRange

Member
This is usually personal problems related to how you wrote your code.
I have no idea what your code does so it's impossible to give you a clear cut solution.
You might want to look into everything you do while starting a new room.
As well learn the debugger.
 
Ok. I know how to use the debugger for the most part. So that strategy is down. Now I don't know how to phrase this, but how can I end up with a memory leak in GMS2?
I know in C++ if you create an object and don't delete it when you are done with it. Is there a similar situation that occurs in GMS2?
 
R

robproctor83

Guest
Take a look at the docs, it kind of discusses this in some regard. But, specifically there are various data types that have to be manually deleted. Any data structure, DS_Grid, DS_List, etc all have to manully deleted. However, to start getting a significant memory leak you would need to be leaking A LOT of data to make things run slow, like a lot. If you forgot to delete a ds list here or there you probably wouldn't notice it (well depending on how big it is).

Other things like Surfaces and Particles also have to be manually deleted. If I had to guess your issue is somewhere around here. There are other things too I am sure, so search around.

Also, you should take a look in debugger and see how many surfaces you have going when it's hanging up. You can do this by pausing the game with debugger and then in the tabs by the output console there should be one called graphics, or something, and in there you will find a drop down for surfaces and texture pages, this should give you some insight into what graphics are currently loaded in the game. Also once it is paused you can inspect objects and other variables, this too should help you figure out things.

And one more tip is to use the profiler. Once you start noticing some lag go into debugger, other and start profiling. This will make the game run a bit slower, but it will record what all is going on. Then, as the game starts to slow down more and more you can refer back to the profiler and see what all objects are taking up the most processing time, and also see what all surfaces and stuff are sucking up memory.
 
Take a look at the docs, it kind of discusses this in some regard. But, specifically there are various data types that have to be manually deleted. Any data structure, DS_Grid, DS_List, etc all have to manully deleted. However, to start getting a significant memory leak you would need to be leaking A LOT of data to make things run slow, like a lot. If you forgot to delete a ds list here or there you probably wouldn't notice it (well depending on how big it is).

Other things like Surfaces and Particles also have to be manually deleted. If I had to guess your issue is somewhere around here. There are other things too I am sure, so search around.

Also, you should take a look in debugger and see how many surfaces you have going when it's hanging up. You can do this by pausing the game with debugger and then in the tabs by the output console there should be one called graphics, or something, and in there you will find a drop down for surfaces and texture pages, this should give you some insight into what graphics are currently loaded in the game. Also once it is paused you can inspect objects and other variables, this too should help you figure out things.

And one more tip is to use the profiler. Once you start noticing some lag go into debugger, other and start profiling. This will make the game run a bit slower, but it will record what all is going on. Then, as the game starts to slow down more and more you can refer back to the profiler and see what all objects are taking up the most processing time, and also see what all surfaces and stuff are sucking up memory.
Ok. I'm checking the debugger right now. But there is definitely something up with the memory/resources. There are 10 levels, made up of 4 stages per level. The longer I play, the slower it gets. So that by the time I get to level 8 it starts pinwheeling. By the time at level 10 it pinwheels and freezes for about 5 seconds. I'm not using any data structures or surfaces.

Also for compilation it takes me like 20 minutes to build and run. That's on a MacBook Air 2017 model. It has an intel core i5 1 GhZ with 8 GB of RAM.


(Edit)

Do TextureGroups have to be destroyed?

(Edit 2)

Running the game in the beginning my memory is 1210.84 MB FPS: 579

(Edift 3)

After running the game for about ten minutes the memory is 1220.0MB and 184 FPS so its not a memory issue then what is it?
 
Last edited by a moderator:
R

robproctor83

Guest
Well, like I was saying in my previous post you need to use the debugger to see what's going on under the hood once it starts lagging. Check out the surfaces tab and the profiler. The profiler is very useful for situations like this. Maybe it's a particular object that's doing this, profiler would tell you that.

If your not able to figure it out using debugger then my next suggestion would be to use the power of deduction. Meaning you need to start removing things from ur game until you figure out the problem.

Best of luck
 
Well, like I was saying in my previous post you need to use the debugger to see what's going on under the hood once it starts lagging. Check out the surfaces tab and the profiler. The profiler is very useful for situations like this. Maybe it's a particular object that's doing this, profiler would tell you that.

If your not able to figure it out using debugger then my next suggestion would be to use the power of deduction. Meaning you need to start removing things from ur game until you figure out the problem.

Best of luck
Ok. I've been using the debugger but you wouldn't happen to know how to open the profiler on a Mac would you? Its different than on a PC.

I checked the surfaces tab and there wasn't any listed.
 
R

robproctor83

Guest
There wasn't ANY? You must not be checking it right. You have to PAUSE the game with debugger and then hit the refresh button (its a little refresh button by where they should be listed, I forget exactly). You should have at minimum 1 I think, the application surface.

And regarding mac, no I can't help with that unfortunately... But it can't be that different. On PC the profiler is listed onder the OTHER tab of the output console.
 
If you can't see the Profile Window, you can open it from the Menu under Debugger->Windows->Profile.

Then, while the game is running in Debug Mode, you have to click the Start Profiling Button in the Profile window.

There will be a column called Time and Step %, click on the column title to sort from highest to lowest.

Whatever is listed at the top/highest value is taking the most amount of processing time per step. The name of the instances are given in the left hand column, and that's where you will want to start investigating once you have the names of the culprits.

I would also check the All Instances window. Check that you have the expected amount of instances that would be normal for your game. An excessive amount - or if you notice the number of instances increasing over time for no reason, would eventually slow the game down as they consume processing power.

Debugger Manual Page just as a reference.
https://docs2.yoyogames.com/index.html?page=source/_build/2_interface/2_extras/debugging.html
 
Top