releasing a list
Posted: 31 Oct 2014 14:27
Will lists, not referenced any longer, be released when I remove the variable the list pointer has been assigned to?
Specifically, I am using/toying with some code, using nested lists for intermediate storage.
It looks, for example, like this:
After that "for (words in app)" loop i don't need that nested list any longer, and want to release it. It may be re-created again elsewhere in the script. Is what I'm trying here enough for doing so? I'm also wondering whether I should bother at all, given that intermediate list items, the beef of the list, still float around in memory, by re-referencing them from the mem list (as intended), and there may be little to gain. Main consideration was memory usage, as those nested lists can grow to non-neglectable number of items (several thousand to ten thousands).
Specifically, I am using/toying with some code, using nested lists for intermediate storage.
It looks, for example, like this:
Code: Select all
// intermediate list of lists. Meant for avoiding long sequences of addElement(mem,...)
// There's a reason why I don't write this as mem=newList(<list_of_all_items_in_nested_lists>);
app=newList(
newList(here,over,comma,swap,store),
newList(here,over,allot,swap,cmove),
newList(...),
newList(bye)
);
// now looping through nested list "app", copying references to contents to list mem:
for (words in app) { // loop through lists
for (word in words) { // loop through list items
addElement(mem,word)
}
}
// nested lists "words" not needed any longer. Release?
removeVariable(app);