Memory allocation failed, can anyone explain the problem?

X

xX_Storm_Xx_2000

Guest
___
############################################################################################ FATAL ERROR in
action number 1
of Alarm Event for alarm 0 for object obj_gen_xs:

Memory allocation failed: Attempting to allocate 2097672 bytes
at gml_Object_obj_gen_xs_Alarm_0 ############################################################################################
--------------------------------------------------------------------------------------------
stack frame is gml_Object_obj_gen_xs_Alarm_0 (line -1)

Can anyone explain the problem? And if you can come up with some possible solutions that would be a big help.
 

FrostyCat

Redemption Seeker
Stop posting just the error message. Post the allocation code in that event, the corresponding cleanup code and where that cleanup code comes from. Do that between [code] and [/code] tags. Read the posting guidelines.

From what the error looks like, you're probably allocating things like surfaces or buffers step over step without cleaning after them. You have to keep in mind at all times that GML is not a garbage-collected language in general.
 
I have a game with a similar error code, and that is literally all the info that I have.

It's pointing to a create event of a sprite that is a solid square with a single line:

Code:
image_alpha = 0
The game takes forever to crash, and I'm not explicitly allocating memory anywhere.

I've unchecked "Visible" and deleted the event to see where it crashes now, but I can't find any useful information anywhere.[/code]
 

Nidoking

Member
Sprites don't have Create events. They don't have events at all. Objects have events, and instances of those objects run events. So what you're saying is that you've made a game with nothing in it but (presumably) a room, one object with only a Create event that does nothing but set it to be transparent, a single sprite, and one instance of that object in your single room, and that's crashing your game? I think you literally have more information than what you've provided, and it will literally be required if you intend to ask an answerable question. At least use the debugger to see what instances exist in your game, what custom variables they have, and how big the arrays or data structures you're using are.

Also, memory allocations may be implicit, but that doesn't take up any less memory. You're either making too much of something, or you're making too many things.
 
Edited to remove unnecessary info relating to the crash which has now been solved.

Sprites don't have Create events. They don't have events at all. Objects have events, and instances of those objects run events. So what you're saying is that you've made a game with nothing in it but (presumably) a room, one object with only a Create event that does nothing but set it to be transparent, a single sprite, and one instance of that object in your single room, and that's crashing your game? I think you literally have more information than what you've provided, and it will literally be required if you intend to ask an answerable question. At least use the debugger to see what instances exist in your game, what custom variables they have, and how big the arrays or data structures you're using are.

Also, memory allocations may be implicit, but that doesn't take up any less memory. You're either making too much of something, or you're making too many things.
Yeah, I mistyped. It's the object's create event.

I should probably clarify and say that this isn't *my* game. I'm a TA for a university course using GMS2 to introduce people into CS and programming. I've since figured out the issue and the code kept loading the same room every step. The error being given wasn't helpful, and using the debug options weren't responsive enough to see what was going on when I was trying to assist via a screen share.
 
Last edited:

Nidoking

Member
The error being given wasn't helpful,
Well, it does tell you the object (obj_gen_xs) and the event (Alarm 0) where it was crashing, and you chose not to post anything from that event by way of explaining the problem. That could have been helpful. As a TA, I hope you can get that much information from an error message.
 
I said it was a similar error code, not the same.

Now that I have fixed the error (which may or may not have the same reason as op for occurring) the code makes sense. But in the moment telling me that a create event for an object who's instances aren't created by script or event code, and only contains 1 line (and I was able to replicate it with 0 lines in the object and got the same error) wasn't helpful in the moment for figuring it out.

Especially because this thread was the only one that seemed to have the relevant information and it was unresolved.
 

Nidoking

Member
Ah, I see that you resurrected a thread from years ago instead of making a new one and putting the actual error you got into it.
 
Top