• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • 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.

Question - IDE [Answered] Does the ds_* generates real memory leak?

NicoFIDI

Member
I was wondering if the data structure generates memory leak inside the aplication, or in the ram.
for example if i make

on game start
Code:
ds_grid_create(100,100);
game_restart();
will my PC lose all the ram?
or it will be released when the aplication ends?
 

FrostyCat

Redemption Seeker
If you don't call the corresponding "destroy" function, data structures remain in memory until a hard exit (i.e. the process disappears off the OS altogether). Your example would constitute a memory leak because game_restart() is not a hard exit.
 
P

psyke

Guest
If you change the room or destroy an object without freeing the data structures or resources, your game will have lots of memory leaks.
GMS2 has a new event called "Clean Up Event", which was made to free resources from the memory. You should put all ds_*_destroy() functions on that event.
 

NicoFIDI

Member
Just to avoid more people to get in and explain about memory leaks,
i know how to handle memory leaks,
i alctually had to make my own data structures in C language
my question was about if the game maker memory leaks means:
"real" memory leak (not release ram once the program it's closed).
or "aplication" memory leak (make your aplication take more and more ram but release it when it crush)
 

NicoFIDI

Member
Nop Fel666.

The ram needs active eletricity to store data.
when you power off or restart your pc the memory it's released without OS intervention.
but it's not the same that the aplication takes a lot of ram (ejample: "MINECRAFT")
or having a aplication take ram away from you until you restart your PC (called: memory leak)

in the programs that run into a virtual machine that's not a problem, because they have garbage collector.
but in C, you can actually take the memory until you power off the ram, if you dont handle it correctly.
 
Last edited:

zbox

Member
GMC Elder
The OS will pretty much always free all the memory allocated by a program once it terminates, regardless of if it's written in C or GM
Nop Fel666
The ram needs active eletricity to store data.
when you power off or restart your pc the memory it's released without OS intervention.
but it's not the same that the aplication takes a lot of ram (ejample: "MINECRAFT")
or having a aplication take ram away from you until you restart your PC (called: memory leak)
School'd Fel666, who knew RAM needs electricity to work eh ;)?
 

GMWolf

aka fel666
Nop Fel666.

The ram needs active eletricity to store data.
when you power off or restart your pc the memory it's released without OS intervention.
but it's not the same that the aplication takes a lot of ram (ejample: "MINECRAFT")
or having a aplication take ram away from you until you restart your PC (called: memory leak)

in the programs that run into a virtual machine that's not a problem, because they have garbage collector.
but in C, you can actually take the memory until you power off the ram, if you dont handle it correctly.
Even when writing in C, the OS has got your back.
When allocating memory, you are not actually interfacing directly with the hardware. You are asking the OS to allocate memory.
The oS interfaces with the hardware and allocated memory. What it returns to the software is a virtual address space.
This means that programs are isolated from each other (a pointer in one program can have the same value as a pointer in another program without them being the same physical adress).

The os keeps track of what memory is allocated to what process, and when the process ends, it marks the memory as free, ready to be reused by another process (it may even clear the memory for security, but not necessarily).

You can easily test this yourself:
Create a C program that calls calloc continually. When it reaches 2 GB of mem usage or so, kill it, and obsrve your ram usage.
 
Last edited:

NicoFIDI

Member
I didnt know that OS update D:
it's nice to know that now they take care of it :D
welp, with that knowledge the post didnt actually make any sense.
thanks @Fel666 :)
 
Top