Jump to content

Disposing of variables to free script memory


w1zard
 Share

You are about to reply to a thread that has been inactive for 4666 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

No, that won't remove the variable.  You can empty the contents of a list by writing  existing_list = []; , which will save you memory that was being used to store any previously loaded values, but it will leave the variable itself intact. 

Link to comment
Share on other sites

The memory usage displayed using
 

(string)llGetFreeMemory()

 Doesnt give a higher value after using
 

existing_list = []; 

 either. Does this mean that once you have used memory, it is not possible to dispose of that memory?

Link to comment
Share on other sites

So if I hit 100% memory usage, and even though I clear the list using = [];  ,I will get memory usage errors when I start adding to the list, because the old data is still being held in memory by the script instance? or do you mean that just the llGetFreeMemory counter doesnt go back up again? Please say its the later.

Link to comment
Share on other sites

in LSO it's a high water mark (the most memory used so far), in MONO it's what the script is currently using, including memory for items that have not been garbage collected yet.

so in LSO clearing a list won't show, but that memory IS available again (with minor caveats for fragmentation), in MONO it will read correctly AFTER garbage collection, but is still usable in some scenarios (like reassigning a just cleared variable). Garbage collection in MONO should happen on event exit or state change, so reading free memory after one of those should give proper results.

Link to comment
Share on other sites

1)

If you compile in mono , you may replace llGetFreeMemory by llGetUsedMemory

http://wiki.secondlife.com/wiki/LlGetUsedMemory

 

llGetFreeMemory returns the top of the used stack  and doens t pay attention to the fragmentation of memory .

llGetUsedMemory returns the memory used and pays attention to the fragmentation of memory

 

2) if you use some huge lists or some huge strings , and if you call some functions with list or string in parameters , you may fail in stack heap collision even if you have got enough memory .

It s because the arguments of functions are passed by value and not by reference

write

myList = llDeleteSubList((myList=[])+myList, 0, 0);

instead

myList = llDeleteSubList(myList, 0, 0);
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4666 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...