Difference between revisions of "User:Daemonika Nightfire/Scripts/Memory Walkthrough"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "==Memory Walkthrough== This Script show you how you can limit the maximal memory for each script. Note: you need the following group to visit the BlueSteel Sandbox: secondlife://…")
 
Line 1: Line 1:
==Memory Walkthrough==
==Memory Walkthrough==
This Script show you how you can limit the maximal memory for each script.
This Script show you how you can limit the maximal memory for each mono-script.
Note: you need the following group to visit the BlueSteel Sandbox: secondlife:///app/group/19657888-576f-83e9-2580-7c3da7c0e4ca/about that you can test the new funktions.
Note: you need the following group to visit the BlueSteel Sandbox: secondlife:///app/group/19657888-576f-83e9-2580-7c3da7c0e4ca/about that you can test the new funktions.
  sorry for the german description, but i am german :P
  sorry for the german description, but i am german :P

Revision as of 06:45, 13 August 2011

Memory Walkthrough

This Script show you how you can limit the maximal memory for each mono-script. Note: you need the following group to visit the BlueSteel Sandbox: secondlife:///app/group/19657888-576f-83e9-2580-7c3da7c0e4ca/about that you can test the new funktions.

sorry for the german description, but i am german :P

<lsl> /*

   Memory-walkthrough by Daemonika Nightfire (daemonika.nightfire)
   Used commands:
   
   integer llSetMemoryLimit(integer limit)     // legt das maximale Memorylimit fuer das Script fest (verfuegbar ab Server 11.08.08.237997)
   integer llGetMemoryLimit()                  // gibt den Wert des Memorylimits zurueck (verfuegbar ab Server 11.08.08.237997)
   integer llGetUsedMemory()                   // gibt den Wert des gesamten Memory-verbrauchst zurueck (verfuegbar)
   integer llGetFreeMemory()                   // gibt den Wert des freien Memorys zurueck (verfuegbar)
   
   llScriptProfiler(PROFILE_SCRIPT_MEMORY);    // startet Memory-ueberwachung (verfuegbar)
   llScriptProfiler(PROFILE_NONE);             // beendet Memory-ueberwachung (verfuegbar)
   integer llGetSPMaxMemory()                  // gibt den durchschnittlichen Memory-verbrauch des ScriptProfilers zurueck (verfuegbar)
   
   tested on BlueSteel-Sandbox:
   http://maps.secondlife.com/secondlife/BlueSteel%20Sandbox%203/199/180/23
   
  • /

integer limit = 20000; // dient zum festlegen des maximalen Script-Memory-Limits

Test() // meine Funktion {

   // einfache Hovertext-Anzeige
   llSetText("Limited Memory " + (string)llGetMemoryLimit() +
             "\nUsed Memory " + (string)llGetUsedMemory() +
             "\nFree Memory " + (string)llGetFreeMemory(),<1,1,1>,1);

}

default {

   state_entry()
   {
       llSetMemoryLimit(limit);
       
       ///// Memory Profiler: testet den Speicherverbrauch saemtlicher Funktionen unterhalb dieses Befehls
       llScriptProfiler(PROFILE_SCRIPT_MEMORY); // startet Memory-ueberwachung
       
       Test(); // meine Funktion
       
       ///// Memory Profiler: beendet die ueberwachung des Speicherverbrauchs saemtlicher Funktionen oberhalb dieses Befehls
       llScriptProfiler(PROFILE_NONE); // beendet Memory-ueberwachung
       
       ///// gibt den durschschnittlichen Memory-verbrauch der getesteten Funktionen zurueck
       llSay(0,"This script used at most " + (string)llGetSPMaxMemory() + " bytes of memory during Test.");
       
       // Ausgabe sieht Folgendermassen aus:
       
       // Hovertext:
       // Limited Memory 20000
       // Used Memory 4972
       // Free Memory 15100
       
       // Chat:
       // [05:11] Object: This script used at most 4972 bytes of memory during Test.
   }

} </lsl>