• 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.

Windows Debugger ram usage different from windows ram usage

valere

Member
Hi. I'm having a problem with a memory leak in my load function. I'm only using temp variables and I'm not sure where the problem is coming from. GMC debugger shows memory being freed up after function like it should, but it seems like windows doesn't free up the memory and makes the game lag a lot.

Is there any reason the two numbers don't line up ? They do when I launch the game up until I use my load function.

Capture.JPG
 

valere

Member
Even when I simplify my load function to the extreme, I still see this problem arise
Here my simplified load function

GML:
function LoadGame()
{
    if(file_exists("savedgame.save"))
    {
        //read data from file
        var _buffer = buffer_load("savedgame.save");
        var _string = buffer_read(_buffer, buffer_string);
        buffer_delete(_buffer);
        _buffer = -1;
        var _loadData = json_parse(_string);
        delete _string;
        delete _loadData;
               
    }
}

Is there any reason a code like this should left anything in memory ?

The save file is around 4Mo
 
Last edited:

O.Stogden

Member
I'm not sure if GM works in a way where the memory is technically "freed", in that if you make something else, GM can take up the memory, but it doesn't "free" it on the Windows side of things.

So if you had 100MB RAM usage, then made an 8MB data structure, RAM usage goes to 108MB, you free it, the usage stays at 108MB (in Windows), but if you made another 8MB data structure, GM places it in that 8MB, because it knows it's now free. So the RAM usage stays at 108MB, instead of going to 116MB.

That's how I believe it may work, but I'm not sure. And GM probably handles destroying/garbage collection differently for every type of resource.
 

valere

Member
I was wondering if that was the case, but my function starts lagging the game more and more as I use it. So it seems the RAM isn't freed up.
 

O.Stogden

Member
I'm not 100% familiar with json_parse either, it looks like it makes additional resources when you use it, it might be that the "delete _loadData" isn't deleting everything that the json_parse function creates, but like I said, I have no experience with this.

Also make sure your garbage collector is activated with " gc_enable(true); " . It should be enabled by default though.
 
Top