Difference between revisions of "LlGetUsedMemory"

From Second Life Wiki
Jump to navigation Jump to search
m
(memory values are updated only at the start of a server frame, micro sleep before the call to skip to the next frame gets you stable results)
 
(7 intermediate revisions by 6 users not shown)
Line 15: Line 15:
===LSO===
===LSO===


LSO scripts always use 16k of memory.
LSO scripts always use 16KiB of memory.


|caveats=
|caveats=
*Scripts compiled to LSL always report 16k memory used.
*Scripts compiled to LSO always report 16KB memory used.
*This can be called at any time and does '''not''' require [[llScriptProfiler]]
*This can be called at any time and does '''not''' require [[llScriptProfiler]]
|constants
|constants
|examples=
|examples=
Calling llGetUsedMemory can look like this:
Calling llGetUsedMemory can look like this:
<lsl>
<source lang="lsl2">
integer used_memory = llGetUsedMemory();
integer used_memory = llGetUsedMemory();
llOwnerSay((string)used_memory + " bytes of memory currently used.");
llOwnerSay((string)used_memory + " bytes of memory currently used.");
</lsl>
</source>
|helpers
|helpers
|also_functions
|also_functions=
{{LSL DefineRow||[[llGetFreeMemory]]|}}
{{LSL DefineRow||[[llSetMemoryLimit]]|}}
{{LSL DefineRow||[[llScriptProfiler]]|}}
|also_events
|also_events
|also_tests
|also_tests
|also_articles
|also_articles
|notes
|notes=The amount of used memory is updated only at the start of a server frame, meaning the values from this function can fluctuate. To ensure stable values, it's possible to wait until the next frame, e.g. [[llSleep]](0.01) before the call to llGetUsedMemory.
|lso
|lso
|cat1=Script
|cat1=Script
|cat2
|cat2=Memory
|cat3
|cat3
|cat4
|cat4
|history = Date of Release  [[ Release_Notes/Second_Life_Server/11#11.06.17.233176 | 17/06/2011 ]]
}}
}}

Latest revision as of 13:40, 9 October 2023

Summary

Function: integer llGetUsedMemory( );

Returns the integer of the number of bytes of memory currently in use by the script.

Specification

This function's behavior is dependent upon the VM the script is using. Mono is the new VM, LSO is the old VM. The big difference between between Mono and LSO is that Mono scripts run faster and can utilize four times more memory.

Mono

In Mono the value returned is the amount of memory currently in use by the script.

LSO

LSO scripts always use 16KiB of memory.

Caveats

  • Scripts compiled to LSO always report 16KB memory used.
  • This can be called at any time and does not require llScriptProfiler
All Issues ~ Search JIRA for related Bugs

Examples

Calling llGetUsedMemory can look like this:

integer used_memory = llGetUsedMemory();
llOwnerSay((string)used_memory + " bytes of memory currently used.");

Notes

The amount of used memory is updated only at the start of a server frame, meaning the values from this function can fluctuate. To ensure stable values, it's possible to wait until the next frame, e.g. llSleep(0.01) before the call to llGetUsedMemory.

See Also

Functions

•  llGetFreeMemory
•  llSetMemoryLimit
•  llScriptProfiler

Deep Notes

History

Date of Release 17/06/2011

Search JIRA for related Issues

Signature

function integer llGetUsedMemory();