Freeze/crash with no fatal error

L

LV154

Guest
Dear all,

I'm hoping to gain some input from users that are more aware of how GM operates. I currently have a project that freezes on preview and cannot pin point why. It doesn't happen all the time, and have not been able to identify the specific trigger. The exe will run fine and then become completely unresponsive, before the "stopped working" dialog box appears. As there is no fatal error, I'm beginning to question as to whether this is possibly due to some memory leak as the game does utilise external sounds that are supposed to be discarded once the player is far enough from the source.

If it helps, this is on GM 8.1, windows 10. Does anybody have any ideas?
 

samspade

Member
Dear all,

I'm hoping to gain some input from users that are more aware of how GM operates. I currently have a project that freezes on preview and cannot pin point why. It doesn't happen all the time, and have not been able to identify the specific trigger. The exe will run fine and then become completely unresponsive, before the "stopped working" dialog box appears. As there is no fatal error, I'm beginning to question as to whether this is possibly due to some memory leak as the game does utilise external sounds that are supposed to be discarded once the player is far enough from the source.

If it helps, this is on GM 8.1, windows 10. Does anybody have any ideas?
Freezing without an error message implies an endless loop of some kind. The most common, as pointed out, is a while loop. But any loop could do it. For example, do ... until or even a for loop. For example for (var i = 0; i > 10; i -= 1). I would do a search through the code for anything like that.
 

Danei

Member
Try using the profiler included with the debugger to see if it's a memory leak. If not, it does sound like some kind of loop that is never resolving.

If you're using for loops, make sure you're not nesting loops that both use i as their variable, for example (I accidentally do this all the time).
 
L

LV154

Guest
Thanks everyone. Seems like it's going to be a cumbersome task going through the code again. Just to clarify, though, are loading/deleting external resources and the use of alarms to do so, not likely to be the problem? I'm getting the impression that these issues started around the same time sounds were added. However, I don't see why it could cause an issue unless the audio engine is inherently poor. Nevertheless, I'll look into loops as I wasn't aware they could cause an issue. Thanks everyone
 

samspade

Member
Thanks everyone. Seems like it's going to be a cumbersome task going through the code again. Just to clarify, though, are loading/deleting external resources and the use of alarms to do so, not likely to be the problem? I'm getting the impression that these issues started around the same time sounds were added. However, I don't see why it could cause an issue unless the audio engine is inherently poor. Nevertheless, I'll look into loops as I wasn't aware they could cause an issue. Thanks everyone
I don't think so, but it depends on how you do it. For example, if you load something in with a while loop, or if you're using some function or event which doesn't progress until the loading is finished and it never finishes for some reason, then it could be (I'm not familiar with any load event that would do that, but I don't know all of them either).

I can't remember what the search function was in GMS 1 or how good it is, but I know it had one. In GMS 2 you can just search for words like while or for. Otherways to debug stuff like this is to put show debug messages in your code at various points so that the output will show you generally where the game is. You can use this to progressively narrow down when the error is occurring.

Another way to try and locate an error is to remove portions of your code to see if the error stops. For example, remove all saving and loading, see if it crashes. If it never crashes, you could then look through (or post) that code.

But yes, apparently random errors, especially those without messages, can be incredibly annoying to track down. I've spent hours at various points try to figure out what was wrong with my code.
 
Top