GameMaker FATAL ERROR. Memory allocation failed

S

Schekhovtsov

Guest
Hello. Can you tell me what caused the error on Android?

Code:
### FATAL ERROR in action number 1 of Create Event for object ob_achievement

Memory allocation failed
Attempting to allocate 16777216 bytes ###
 

Relic

Member
That message tells you the object and the event that causes the error. You should show us too.

But it is likely that you are out of memory. Make sure to clear surfaces and data structures when you don’t need them any more so the memory is freed for future uses.
 
S

Schekhovtsov

Guest
Here is the code in the Create-event that most likely leads to an error

Code:
surfAreaH = 840;
surfArea = surface_create(720, surfAreaH);
surface_set_target(surfArea);
draw_clear_alpha(c_black,0);
surface_reset_target();
There is in a Room End:

Code:
surface_free(surfArea);
In Draw event:

Code:
if !surface_exists(surfArea)
{
surfArea = surface_create(720, surfAreaH);
surface_set_target(surfArea);
draw_clear_alpha(c_black,0);
surface_reset_target();
}
draw_surface(surfArea, scroll_Xbuff, scroll_Ybuff);

surface_set_target(surfArea);
draw_clear_alpha(c_black, 0);
- - - - -
surface_reset_target();
 

Relic

Member
Surfaces should not be drawn to in any other event than the draw event. That draw clear in the step event should be removed. In fact I think it’s also a no no to even create a surface anywhere other than a draw event - but don’t quote me on that. If in your create event you just had surfArea=noone; then the draw event will kick in to create the surface the first time the draw event happens.

I’d be surprised if that solves your issue but I’m not familiar with limitation of mobile platform.
 
Top