• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

GameMaker out of memory

A

awsome129

Guest
I have been working on this game for sometime now and after implementing blood and gore i get an out of memory error message when i go to my main room in my game that i implemented blood and gore on. I do not want to get rid of the blood system. I have about 13 sprites and 13 objects and 2 sounds but am not using all them in one room. In task manager when the out of memory message comes up, GameMaker is using 800mb's of memory. What should i do as i do not want to abandon this project. I have a good computer with 8gb of RAM. Please help!!!
 

Yal

🐧 *penguin noises*
GMC Elder
800 MB is a lot. Are you sure the blood system works so that it doesn't end up in an infinite loop of spawning more and more blood or something like that?
 

icuurd12b42

TMC Founder
GMC Elder
>now and after implementing blood and gore i get an out of memory error message
It's probably making a huge vertex batch
in the loop that draws the blood and gore, call d3d_set_identity() every 1000 blood and gore draw...
 
A

alpha_centauri

Guest
I have been working on this game for sometime now and after implementing blood and gore i get an out of memory error message when i go to my main room in my game that i implemented blood and gore on. I do not want to get rid of the blood system. I have about 13 sprites and 13 objects and 2 sounds but am not using all them in one room. In task manager when the out of memory message comes up, GameMaker is using 800mb's of memory. What should i do as i do not want to abandon this project. I have a good computer with 8gb of RAM. Please help!!!
is game maker using 800mb or is the player using 800mb
 

Yal

🐧 *penguin noises*
GMC Elder
upload_2016-6-26_4-49-12.png
Is that a pun or a misspelling...?

Also, posting a meme didn't exactly add to the topic in any constructive way.
 
A

awsome129

Guest
>now and after implementing blood and gore i get an out of memory error message
It's probably making a huge vertex batch
in the loop that draws the blood and gore, call d3d_set_identity() every 1000 blood and gore draw...
i understand that is a 3D line and my current game is 2d. As I am new to game maker, could I do that in 2d? Thank you for the reply.
 
A

awsome129

Guest
800 MB is a lot. Are you sure the blood system works so that it doesn't end up in an infinite loop of spawning more and more blood or something like that?
I used a tourtorial for help on this and he did mention using a loop. How do I determine if it is an infinite loop and how would I stop it. Thank you for the reply.
 

Yal

🐧 *penguin noises*
GMC Elder
To clarify, d3d_set_identity() forces an end to the current vertex batch as a side-effect, and if you have issues with batches getting too big, this side-effect can be abused. All 3D functions work in 2D mode, but you won't be able to set up perspective projections (needed to VIEW stuff in 3D) unless you activate 3D mode.
 
A

awsome129

Guest
To clarify, d3d_set_identity() forces an end to the current vertex batch as a side-effect, and if you have issues with batches getting too big, this side-effect can be abused. All 3D functions work in 2D mode, but you won't be able to set up perspective projections (needed to VIEW stuff in 3D) unless you activate 3D mode.
Ok I'll try it ty
 

Roa

Member
Is half the convo missing?? Where did he ever mention 3d or line drawing?

I was going to say run the debug overlay and see what comes up.. but I feel like others know something I don't
 
A

awsome129

Guest
To clarify, d3d_set_identity() forces an end to the current vertex batch as a side-effect, and if you have issues with batches getting too big, this side-effect can be abused. All 3D functions work in 2D mode, but you won't be able to set up perspective projections (needed to VIEW stuff in 3D) unless you activate 3D mode.
So to do this I would
>now and after implementing blood and gore i get an out of memory error message
It's probably making a huge vertex batch
in the loop that draws the blood and gore, call d3d_set_identity() every 1000 blood and gore draw...
ok so to do this I would go into the draw event of the gore system and code this. I am sorry for my questions but I am rather new to gml and only know some basic stuff.
 
A

awsome129

Guest
So to do this I would

ok so to do this I would go into the draw event of the gore system and code this. I am sorry for my questions but I am rather new to gml and only know some basic stuff.[/QUOTE
So to do this I would

ok so to do this I would go into the draw event of the gore system and code this. I am sorry for my questions but I am rather new to gml and only know some basic stuff.
i could include my code of it would help. Thank you
 
A

awsome129

Guest
GM creates 32 bit executables. So it will cap out at around 1.5GB.

I know, a far cry from the 800MB you are using. But, the underlying render system also keeps a copy in system RAM for 'lost devices' etc. So, you are suddenly looking at 1.6GB usage.
that is alot of usage lol i didnt know that
 

icuurd12b42

TMC Founder
GMC Elder
So to do this I would

ok so to do this I would go into the draw event of the gore system and code this. I am sorry for my questions but I am rather new to gml and only know some basic stuff.
yes, find the loop that draws the blood and gore... I assume it's a loop through an array of sprites and position.

add d3d_set_identity() before the loop and add d3d_set_identity() after the loop. if that doesn't work, the loop itself is making a huge batch so call d3d_set_identity() every 1000 draws...

something like if(i mod 1000 == 0) d3d_set_identity() assuming the for loop uses i as the counter.

Is half the convo missing?? Where did he ever mention 3d or line drawing?

I was going to say run the debug overlay and see what comes up.. but I feel like others know something I don't
Could be yes ;)

Here's the whole reasoning. It is very unlikely the out of memory error is related to memory usage. I seen it happen only once due to memory allocation adding item to a list and it took a long time to reach the limit in a for loop.

EDIT d3d

Most time the error happens is due to the vertex batch size. some pcs will show a more descriptive error, some video cards cant handle big batches while other can...

What tipped me what this line about adding blood an gore... it is also possible if the game crashes before adding blood and gore to the system that he's got a deadlock loop somewhere that adds items to a list or array

*d3d_transform_set_identity()
 
  • Like
Reactions: Roa
A

awsome129

Guest
yes, find the loop that draws the blood and gore... I assume it's a loop through an array of sprites and position.

add d3d_set_identity() before the loop and add d3d_set_identity() after the loop. if that doesn't work, the loop itself is making a huge batch so call d3d_set_identity() every 1000 draws...

something like if(i mod 1000 == 0) d3d_set_identity() assuming the for loop uses i as the counter.



Could be yes ;)

Here's the whole reasoning. It is very unlikely the out of memory error is related to memory usage. I seen it happen only once due to memory allocation adding item to a list and it took a long time to reach the limit in a for loop.

Most time the error happens is due to the vertex batch size. some pcs will show a more descriptive error, some video cards cant handle big batches while other can...

What tipped me what this line about adding blood an gore... it is also possible if the game crashes before adding blood and gore to the system that he's got a deadlock loop somewhere that adds items to a list or array
Ok ty I will try that
 
A

awsome129

Guest
yes, find the loop that draws the blood and gore... I assume it's a loop through an array of sprites and position.

add d3d_set_identity() before the loop and add d3d_set_identity() after the loop. if that doesn't work, the loop itself is making a huge batch so call d3d_set_identity() every 1000 draws...

something like if(i mod 1000 == 0) d3d_set_identity() assuming the for loop uses i as the counter.



Could be yes ;)

Here's the whole reasoning. It is very unlikely the out of memory error is related to memory usage. I seen it happen only once due to memory allocation adding item to a list and it took a long time to reach the limit in a for loop.

EDIT d3d

Most time the error happens is due to the vertex batch size. some pcs will show a more descriptive error, some video cards cant handle big batches while other can...

What tipped me what this line about adding blood an gore... it is also possible if the game crashes before adding blood and gore to the system that he's got a deadlock loop somewhere that adds items to a list or array

*d3d_transform_set_identity()
Ok ty I will try that
It says d3d_set_identity isn't a function but d3d_transform_set_identity is, should I use that?
 
A

awsome129

Guest
yes, find the loop that draws the blood and gore... I assume it's a loop through an array of sprites and position.

add d3d_set_identity() before the loop and add d3d_set_identity() after the loop. if that doesn't work, the loop itself is making a huge batch so call d3d_set_identity() every 1000 draws...

something like if(i mod 1000 == 0) d3d_set_identity() assuming the for loop uses i as the counter.



Could be yes ;)

Here's the whole reasoning. It is very unlikely the out of memory error is related to memory usage. I seen it happen only once due to memory allocation adding item to a list and it took a long time to reach the limit in a for loop.

EDIT d3d

Most time the error happens is due to the vertex batch size. some pcs will show a more descriptive error, some video cards cant handle big batches while other can...

What tipped me what this line about adding blood an gore... it is also possible if the game crashes before adding blood and gore to the system that he's got a deadlock loop somewhere that adds items to a list or array

*d3d_transform_set_identity()
ok. i tried to do what u said and it had no effect. I fear i might be coding it in wrong. Here is what i have for the code with the loop, how should i add d3d__transform_set_identity? Thank you

part_emitter_region(obj_blood_contr.partBlood_sys,obj_blood_contr.partBlood_emit,x+5,x-5,y+5,y-5,1,1);
part_emitter_burst(obj_blood_contr.partBlood_sys,obj_blood_contr.partBlood_emit,obj_blood_contr.partBlood,10);

//Create blood on floor
spawn = random_range(10,30);

for (i=0; i<spawn; i++)
{
instance_create(x=random_range(-16,16),y=random_range(-16,16),obj_blood_splatter)
}
 

icuurd12b42

TMC Founder
GMC Elder
OK, so the system is not an array of sprite drawn in a loop but adding instances in the room instead... just how many of these to you have when the game crashes?
 
A

awsome129

Guest
OK, so the system is not an array of sprite drawn in a loop but adding instances in the room instead... just how many of these to you have when the game crashes?
If u mean how many instances of the object(obj_blood_splatter) are in the room when the game is running, the answer is none. As soon as I get into the room that has the object obj_blood_splatter in it, i get the memory leak error.
 
A

awsome129

Guest
OK, so the system is not an array of sprite drawn in a loop but adding instances in the room instead... just how many of these to you have when the game crashes?
if it helps i can post a video of me running the game.
 

icuurd12b42

TMC Founder
GMC Elder
What object is calling the code above? and when? is obj_blood_splatter calling this code that creates 10 instance of the same... because that is a instant boom
 
A

awsome129

Guest
What object is calling the code above? and when? is obj_blood_splatter calling this code that creates 10 instance of the same... because that is a instant boom
. This code is being called when a collision happened between a bullet and an enemy.
 

BarrowBloke

Member
Are you destroying the bullet or enemy?
If you're not then the collision will happen every step and you'll create 10 instances every step. Possibly.
 
A

awsome129

Guest
Are you destroying the bullet or enemy?
If you're not then the collision will happen every step and you'll create 10 instances every step. Possibly.
I am destroying both the enemy and bullet at the collision.
 

BLang

Member
In your obj_blood_contr, in the draw event, change
Code:
if surface_exists(surfBlood)
to
Code:
if !surface_exists(surfBlood)
Otherwise, you're creating a surface every step!



You'll also have to go into obj_blood_splatter and change
Code:
draw_sprite_ext(spr_blood,0,x,y,image_xscale,image_yscale,0,c_white,image_alpha)
to
Code:
draw_sprite_ext(spr_bloodplatter,0,x,y,image_xscale,image_yscale,0,c_white,image_alpha)


Then, in your scr_blood script, change
Code:
instance_create(x=random_range(-16,16),y=random_range(-16,16),obj_blood_splatter)
to
Code:
instance_create(x+random_range(-16,16),y+random_range(-16,16),obj_blood_splatter)

Then, in the create event of obj_blood_splatter, change
Code:
direct = random(359);
to
Code:
direction = random(359);
There's still some bugs, but I don't have the time to figure them all out right now.
Feel free to ask if you need any of the changes I suggested explained! :D
 

icuurd12b42

TMC Founder
GMC Elder
OK well it's not the blood spatter tha crashes, that yelds this error

Variable obj_blood_splatter.spr_blood(100019, -2147483648) not set before reading it.
at gml_Object_obj_blood_splatter_StepNormalEvent_1 (line 16) - draw_sprite_ext(spr_blood,0,x,y,image_xscale,image_yscale,0,c_white,image_alpha)


I used you test room and re-added an instance of every object in there and I dont get the out of memory error

I'm sure there is a condition in your level room by the way to objects are laid out that is causing something to go haywire.

Also trim you sprites. I dont see the reason why you have sprites 32x32 take 1024x1024 of space...

tip to locate the problem...

place
show_debug_message("object name here:event name here <start>") at the top of each event
and
show_debug_message("object name here:event name here <end>") at the bottom of each event.

run the game and the output window in studio should display
object name:event name <start>
object name:event name <end>
object name:event name <start>
object name:event name <end>
object name:event name <start>
object name:event name <end>
object name:event name <start>
object name:event name <end>
object name:event name <start>
BOOM the end is not showing something is wrong with this object
you can then add more show_debug in the object function to find exactly where the blow up happens, pin point a function called and to the same in the function... That is what I would have to resign to do. but the experience is yours to acquire so do that
 
A

awsome129

Guest
In your obj_blood_contr, in the draw event, change
Code:
if surface_exists(surfBlood)
to
Code:
if !surface_exists(surfBlood)
Otherwise, you're creating a surface every step!



You'll also have to go into obj_blood_splatter and change
Code:
draw_sprite_ext(spr_blood,0,x,y,image_xscale,image_yscale,0,c_white,image_alpha)
to
Code:
draw_sprite_ext(spr_bloodplatter,0,x,y,image_xscale,image_yscale,0,c_white,image_alpha)


Then, in your scr_blood script, change
Code:
instance_create(x=random_range(-16,16),y=random_range(-16,16),obj_blood_splatter)
to
Code:
instance_create(x+random_range(-16,16),y+random_range(-16,16),obj_blood_splatter)

Then, in the create event of obj_blood_splatter, change
Code:
direct = random(359);
to
Code:
direction = random(359);
There's still some bugs, but I don't have the time to figure them all out right now.
Feel free to ask if you need any of the changes I suggested explained! :D
ty so much man
 
Top