LlSetMemoryLimit: Difference between revisions
Jump to navigation
Jump to search
Created page with "<!-- {{LSL Generic/RC|RC Magnum}} --> {{LSL_Function |mode=pre-release |func_id=???|func_sleep=0.0|func_energy=??? |func=llSetMemoryLimit |return_type=integer |fu…" |
Lady Sumoku (talk | contribs) m Replaced old <LSL> block with <source lang="lsl2"> |
||
(23 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
{{LSL_Function | {{LSL_Function | ||
|func_id=???|func_sleep=0.0|func_energy=??? | |func_id=???|func_sleep=0.0|func_energy=??? | ||
|func=llSetMemoryLimit | |func=llSetMemoryLimit | ||
|return_type=integer | |p1_type=integer|p1_name=limit | ||
|func_desc= | |return_type=integer|return_subtype=boolean | ||
|Return_text= | |func_desc=Request {{LSLP|limit}} bytes to be reserved for this script. | ||
|Return_text=[[TRUE]] if the memory limit was successfully set (or [[FALSE]] if not). | |||
|func_footer | |func_footer | ||
|spec= | |spec= | ||
This function's behavior is dependent upon the VM the script is using. [[#Mono|Mono]] is the new VM, [[#LSO|LSO]] is the old VM. | This function's behavior is dependent upon the VM the script is using. [[#Mono|Mono]] is the new VM, [[#LSO|LSO]] is the old VM. | ||
;Mono: | ;Mono:Sets the memory limit for the script. | ||
* The memory limit can be set up to 64k. | |||
* The memory limit can not be set lower than the memory currently in use by the script. | |||
* All new scripts start with a limit of 64k | |||
* Mono scripts compiled before this function was introduced continue to use the 64k limit. | |||
* A lower limit will effect the amount of memory reported in the viewer UI and by [[llGetObjectDetails]]. | |||
* The memory limit is not the amount of real memory actually used by the script, just the upper limit on it. | |||
;LSO: | ;LSO:Has no effect on LSO scripts which will always use exactly 16k | ||
|caveats | |caveats= | ||
;Mono:When '''''n''''' is too small, llSetMemoryLimit('''''n''''') is ignored and the memory limit is not changed | |||
|examples | |examples= | ||
<source lang="lsl2"> | |||
// Memory-walkthrough by Daemonika Nightfire (daemonika.nightfire) | |||
integer limit = 20000; // <- bytes | |||
Test() | |||
{ | |||
llSetText("Limited Memory " + (string)llGetMemoryLimit() + | |||
"\nUsed Memory " + (string)llGetUsedMemory() + | |||
"\nFree Memory " + (string)llGetFreeMemory(),<1,1,1>,1); | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
llSetMemoryLimit(limit); | |||
llScriptProfiler(PROFILE_SCRIPT_MEMORY); | |||
Test(); | |||
llScriptProfiler(PROFILE_NONE); | |||
llSay(0,"This script used at most " + (string)llGetSPMaxMemory() + " bytes of memory during Test."); | |||
} | |||
} | |||
// Result: | |||
// Floating Text: | |||
// Limited Memory 20000 | |||
// Used Memory 4972 | |||
// Free Memory 15100 | |||
// Chat: | |||
// [05:11] Object: This script used at most 4972 bytes of memory during Test. | |||
</source> | |||
|helpers | |helpers | ||
|also_functions= | |also_functions= | ||
{{LSL DefineRow||[[llScriptProfiler]]|}} | |||
{{LSL DefineRow||[[llGetSPMaxMemory]]|}} | |||
{{LSL DefineRow||[[llGetMemoryLimit]]|}} | |||
{{LSL DefineRow||[[llGetFreeMemory]]|}} | {{LSL DefineRow||[[llGetFreeMemory]]|}} | ||
{{LSL DefineRow||[[llGetUsedMemory]]|}} | {{LSL DefineRow||[[llGetUsedMemory]]|}} | ||
Line 32: | Line 76: | ||
|cat3=Script Profiler | |cat3=Script Profiler | ||
|cat4 | |cat4 | ||
|history = Date of Release [[ Release_Notes/Second_Life_Server/11#11.08.10.238207 | 10/08/2011 ]] | |||
}} | }} |
Latest revision as of 14:24, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Specification
This function's behavior is dependent upon the VM the script is using. Mono is the new VM, LSO is the old VM.
- Mono
- Sets the memory limit for the script.
- The memory limit can be set up to 64k.
- The memory limit can not be set lower than the memory currently in use by the script.
- All new scripts start with a limit of 64k
- Mono scripts compiled before this function was introduced continue to use the 64k limit.
- A lower limit will effect the amount of memory reported in the viewer UI and by llGetObjectDetails.
- The memory limit is not the amount of real memory actually used by the script, just the upper limit on it.
- LSO
- Has no effect on LSO scripts which will always use exactly 16k
Caveats
- Mono
- When n is too small, llSetMemoryLimit(n) is ignored and the memory limit is not changed
Examples
// Memory-walkthrough by Daemonika Nightfire (daemonika.nightfire)
integer limit = 20000; // <- bytes
Test()
{
llSetText("Limited Memory " + (string)llGetMemoryLimit() +
"\nUsed Memory " + (string)llGetUsedMemory() +
"\nFree Memory " + (string)llGetFreeMemory(),<1,1,1>,1);
}
default
{
state_entry()
{
llSetMemoryLimit(limit);
llScriptProfiler(PROFILE_SCRIPT_MEMORY);
Test();
llScriptProfiler(PROFILE_NONE);
llSay(0,"This script used at most " + (string)llGetSPMaxMemory() + " bytes of memory during Test.");
}
}
// Result:
// Floating Text:
// Limited Memory 20000
// Used Memory 4972
// Free Memory 15100
// Chat:
// [05:11] Object: This script used at most 4972 bytes of memory during Test.
See Also
Functions
• | llScriptProfiler | |||
• | llGetSPMaxMemory | |||
• | llGetMemoryLimit | |||
• | llGetFreeMemory | |||
• | llGetUsedMemory | |||
• | llGetObjectDetails |