X
XirmiX
Guest
Wondering what would happen in these cases to lists and maps. Picture that they are in a script, and when a script is called with either of these pieces of code in, I'm interested in knowing what will happen in terms of garbage collection; will the list or map be destroyed or hang around filling up memory the more it is called? Here are the two examples using a ds_list:
This is just the same thing, but the variable holding a reference to it is not declared with a "var" prefix:
I am asking because I know that ds_list_destroy() exists in GML and the problem is that there is no way to use this function at any point because the list needs to be returned. If in both of these cases the garbage collector doesn't remove these lists from memory, is there some better way I could handle this while still getting the desired result?
Code:
var thrownParameter = argument[0];
var newList = ds_list_create();
var newParameter = thrownParameter++;
ds_list_add(newList , newParameter);
return newList;
Code:
var thrownParameter = argument[0];
newList = ds_list_create()
var newParameter = thrownParameter++;
ds_list_add(newList , newParameter);
return newList;