Request limit bytes to be reserved for this script.

Syntax

integer llSetMemoryLimit( integer limit );

Forced delay: 0.0 seconds. Energy: ???.

Parameters

integer limit

Return value

Returns a boolean (an integer) TRUE if the memory limit was successfully set (or FALSE if not).

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.
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

Deep notes

History

Date of Release 10/08/2011