LSL Wiki Mirror : llGetFreeMemory

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
integer llGetFreeMemory()

Returns the free memory available, in bytes, to the script calling it. Free memory means 16kb (the maximum each script gets) minus the size of the script's bytecode, stack, and heap.

NOTE: The above statement I have found to be untrue & should be ammended to exactly as LL has it stated in the client: "returns the available heap space for the current script". SiRiSAsturias

As of SL 1.10.6 (July 16, 2006), this function remains broken!
llGetFreeMemory will not take into account memory that has been freed, which can result in far less free memory reported than actually exists. What it will report is the historic free memory--the smallest free memory up until that point. So, in theory, your script could have nearly 16kb free, but report only several bytes free. Depending on what you need, this isn't necessarily a bad thing, but if you're relying upon llGetFreeMemory to know when a script is "full", you may run into some problems.

The historic free memory problem could potentially cause a situation where your script has several kilobytes of memory free, but "thinks" it only has a few bytes available. Other than to suggest that you attempt to design your script in such a way that this can't happen, there isn't a workaround for this situation.

Q: Does llResetScript also reset the historic low memory mark?
A: Yes.


Functions | Memory
There are 3 comments on this page. [Display comments/form]