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

Game getting slower & slower

W

wzspdw

Guest
Hey guys, I've working on a small tower-defence game for months, but recently I found out that my game would getting more and more stuck, but after restart the game the problem disappearred no matter I starting a new game nor loading old game data, any help?
 
L

LazyEpic

Guest
You most likely have a memory leak or you aren't cleaning up something like an object or sprite that gets added over and over again but never gets destroyed.

My first guess would be that you are creating maybe a data struct or something for pathing? do you create a new one with each object? if so are you also removing them correctly?
 
W

wzspdw

Guest
You most likely have a memory leak or you aren't cleaning up something like an object or sprite that gets added over and over again but never gets destroyed.

My first guess would be that you are creating maybe a data struct or something for pathing? do you create a new one with each object? if so are you also removing them correctly?
Hi ~ Since there are more resources , buildings & units to go every single step ,I did destory useless instances , empty arrays and other data structures and make sure they are minimized. Should I code something to detect how long does it take to execute a single step?
 
L

LazyEpic

Guest
Hi ~ Since there are more resources , buildings & units to go every single step ,I did destory useless instances , empty arrays and other data structures and make sure they are minimized. Should I code something to detect how long does it take to execute a single step?
That's actually not a bad idea, then you can have the compile window spit out how long each loop took and maybe pinpoint where you are getting stuck :)
 
J

Jaqueta

Guest
That can be a problem too, Particles, Particle Systems and Emmiters do consume memory, make sure to destroy them after they aren't necessary anymore.

The same goes for everything that are created on the run, Surfaces, Resources, Data Structures, External Files...
 

hippyman

Member
Not sure why nobody has mentioned it yet, but use GM's profiler. It's literally made specifically for cases like this.




EDIT: In case you're not familiar with the debugger, just set one of the window types to "profiler" and click the little circle so that it is red while the game is running and it will start filling up with information on your game.
 
W

wzspdw

Guest
Thx for ur replies all, I've found that there would be one step slower than others every thirteen steps.I've set room speed to 30 and most steps take about 33ms to execute but 1/13 of them takes much more time, almost 130ms after running for 60mins and it continues to growth. I'm still try to find out the exact problem.
 
Top