S
Soulie
Guest
Hi again all,
I've been struggling with a memory leak the last few months.
Is there a method of seeing what lines of code are causing the leak?
I have a ds_list of trees called 'treelist' in my endless game that are added to the list at the right of the screen and deleted when they move past the left side.
in the Room End event I've written: ds_list_destroy(treelist); which frees ds_list from memory (I hope!)
I tried going through each line with the debugger to see when the memory usage increased. It does seem to only happen when the trees are scrolling across the screen and so here is the relevant code:
I have a feeling that after a ds_list array has been copied to the local variable temp_array, the memory for temp_array is not getting freed. Is this possible?
Any suggestions are welcome, really! It's been troubling me too long haha!
(I hope it's just a simple mistake that I've made)
Maybe there's a good method to troubleshoot memory leaks in GM?
Many, many thanks guys,
I've been struggling with a memory leak the last few months.
Is there a method of seeing what lines of code are causing the leak?
I have a ds_list of trees called 'treelist' in my endless game that are added to the list at the right of the screen and deleted when they move past the left side.
in the Room End event I've written: ds_list_destroy(treelist); which frees ds_list from memory (I hope!)
I tried going through each line with the debugger to see when the memory usage increased. It does seem to only happen when the trees are scrolling across the screen and so here is the relevant code:
Code:
if (num_trees > 0)
{
//Copy tree 0's 2D array
var temp_array = treelist[| 0];
// if the x-coordinate is to the left of the view
if (temp_array[0,0] < view_xview[0] - 0.2 * view_wview[0])
{
ds_list_delete(treelist, 0);
num_trees = ds_list_size(treelist);
temp_array = treelist[| 0];
}
// Tree and Branches movement
var i_tree = 0
// Iterate through trees
do
{
var temp_array = treelist[| i_tree];
// move the current x co-ord of tree
temp_array[0,0] -= screen_move
// get the num of branches of this tree
var branches = array_height_2d(temp_array);
for(var j = 1 ; j < branches; j += 1;)
{
temp_array[j, 0] -= screen_move;
temp_array[j, 2] -= screen_move;
}
// copy the tree's modified array back to the ds_list
treelist[| i_tree] = temp_array;
i_tree++;
}
until (i_tree >= num_trees);
}
Any suggestions are welcome, really! It's been troubling me too long haha!
(I hope it's just a simple mistake that I've made)
Maybe there's a good method to troubleshoot memory leaks in GM?
Many, many thanks guys,