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

Gamemaker filling up memory

Hey everyone,

I've been working on an artificial inteligence using gamemaker 1.4 and I developed a working solution.

However, when I start it and let it run for many generations, it starts to fill up my memory up to 1.5gb when i let it run for long enough until it sends the 'out of memory' message and shuts down.

The only thing it really does is writing and reading hundrets of pretty huge arrays every generation. The total number of array doesn't change tho. So I can't find a reason why the memory usage keeps increasing.

I would really appreciate if you could help me with this.

Thank you
 
As I said, it's not much happening

I am mainly creating arrays. I thought there might be a known problem with arrays or something.
Anyway, this is the code responible for most of the array createt every generation:

GML:
//create Synapses
//input - Hidden
for (j=0;j<global.input;j+=1)
{
    for (i=0;i<global.hidden;i+=1)
    {
        if(global.firs_gen = 1)
        {
            input_synapse[j,i] = random_range(-3,3)
        }
        else {input_synapse[j,i] = par.input_synapse[j,i] + random_range(-global.mutation,global.mutation)}
    }
}


//hidden - hidden

for(h=0;h<global.hiddens-1;h+=1)
{
    for (j=0;j<global.hidden;j+=1)
    {
        for (i=0;i<global.hidden;i+=1)
        {
            if(global.first_gen = 1)
            {
                hidden_synapse[j,i] = random_range(-3,3)
            }
            else {hidden_synapse[j,i] = array_3d_get(par, all_hidden_syn, h, j, i) + random_range(-global.mutation,global.mutation)}
        }
    }
    all_hidden_syn[h] = hidden_synapse
}
there are some more similar sections

the accessing part looks like this:

GML:
//output
for(h=0;h<global.output;h+=1)
{
    for(i = 0;i<global.hidden;i+=1)
    {
        neurons[global.hiddens + 1,h] += neurons[global.hiddens,i] * output_synapse[h,i]
    }
    neurons[global.hiddens + 1,h] = (scr_sigmoid(neurons[global.hidden_layers + 1,h] + output[0,h]))
}
and the array_3d_get() sript for accessing my 3d array workarround:

GML:
/// array_3d_get(instance, array, x1, y1, z1) = value;

var inst = argument[0],
var out_array = argument[1],
    x1 = argument[2],
    y1 = argument[3],
    z1 = argument[4];

with(inst) var in_array = out_array[x1];

return (in_array[y1, z1]);
 
If you're passing arrays through functions, remember that GMS copies the array. If you use an array in a function, be sure to use the @ accessor to change the original array, rather than the copy. No idea if this is the problem, but I'm not seeing any accessors and there's a lot of arrays being used, so it might be the cause of the leak.
 
If you're passing arrays through functions, remember that GMS copies the array. If you use an array in a function, be sure to use the @ accessor to change the original array, rather than the copy. No idea if this is the problem, but I'm not seeing any accessors and there's a lot of arrays being used, so it might be the cause of the leak.
Thank you for the tip, I hadn't thought about this.
Unfortunately it doesn't fix the problem

I updated the array access script:
GML:
/// array_3d_get(instance, array, x1, y1, z1) = value;

var inst = argument[0],
var out_array = argument[1],
    x1 = argument[2],
    y1 = argument[3],
    z1 = argument[4];

with(inst) var in_array = out_array[@ x1];

return (in_array[@ y1, z1]);
 
Top