Is glitching/crash due to global variables?????

knightshaft

Member
I'm nearing the end of completing my game. The opening room is the menu screen (loads fine), all the options in the menu work fine except for the 'Start' option. On a Mac I get the beach ball and/or glitching graphics for 1-2 seconds then it runs as it should. On an Amazon Fire tablet it just quits. So that leaves me only being able to test further on the Mac.

The 'Start' option takes you to 'level 1' where all global variable are initilized for the first time. BUT..... they are also initilized in every subsequent level without glitching. There is also NO glitch when the game restarts and goes back to level 1.

So essentially (unless I am missing something) the issue is with the first encounter with the global variables.

I read that global are carried between rooms and with game_restart. So my question is....Does the first initilization require more processing/CPU power then subsequent initilizations?
 

TheouAegis

Member
Try making an empty room and put it at the very top of the resource tree. Open the room settings code box and initialize ALL your global variables there. Then put room_goto_next() at the end.

A lot of things happen on initialization. It does sound like a memory allocation issue, but just setting variables shouldn't cause that much slowdown.
 

knightshaft

Member
Try making an empty room and put it at the very top of the resource tree. Open the room settings code box and initialize ALL your global variables there. Then put room_goto_next() at the end.
Cheers. I was looking at that way. I did a few tests to see how the varibales were being carried around.


It does sound like a memory allocation issue, but just setting variables shouldn't cause that much slowdown.
What else is carried between rooms? It has to be to be smoething along those lines as it only happens once per loading of the game, no matter if its YM,YYC in either GMS2 or executable
 

TheouAegis

Member
Are your rooms persistent? If the answer is no, double-check anyway.

The only other "big" thing I can think of are texture page sizes.

Do long loops cause the cursor to ball up? What happens if you call
Code:
repeat room_speed*60 var a=0;
Also, are you saying the global boot room moves the slowdown to before the main menu, or are you saying level 1 still has slowdown even with the boot room? If the boot room doesn't affect when the slowdown happens, then it's not the global variables (you should still use a boot room, though).

Any large arrays? GM only handles arrays up to 32000 entries long. Anything beyond that requires GM to create a new array, which is somewhat slow (not ball cursor slow, but still slow).
 

knightshaft

Member
Rooms are not persistant. Not moved my variables yet, will do it tonight. The only 'ball up' is the one I have described. Textures could be an issue. Originally the background of the room was made up of 5 fairly low rez png files, now its probably about 100 files with some at full HD overlaying each other. When running the game GMS2 gives piles of warnings about resizing textures.
 
Top