Difference between revisions of "Talk:LSL Script Memory"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
Has anyone tested the new MONO environment for memory usage? It seems its very different from the previous LSO numbers... I think a new section for MONO is needed.--[[User:Darwin Recreant|Darwin Recreant]] 21:21, 4 December 2008 (UTC)
Has anyone tested the new MONO environment for memory usage? It seems its very different from the previous LSO numbers... I think a new section for MONO is needed.--[[User:Darwin Recreant|Darwin Recreant]] 21:21, 4 December 2008 (UTC)
== Size of Strings under Question ==
Unsure of code used by others to determine the size of a local string under Mono but my testing seems to show that a string is approximately 24 bytes + 1 per char. This is the code I'm using with the length of variable "i" such that the addition of one more character causes another page being allocated for memory used. Uncommenting each Test in turn and rerunning it with one additional character in any of the string variables (to show that you are actually at the edge of a page) should show you what I'm finding. Perhaps I'm misinterpreting the results???
<LSL>default
{
    state_entry()
    {
        // Test 1, add one char to string for memory jump of a page
        string i = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn";
        // Test 2 - difference of 32 bytes in variable "i"
        // string i = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi";
        // string j = "a";
        // Test 3 - difference of 27 bytes in variable "i"
        // string i = "abcdefghijklmnopqrstuvwxyzabcdefgh";
        // string j = "a";             
        // string k = "b";
        // Test 4 - difference of 26 bytes in variable "i"
        // string i = "abcdefgh";
        // string j = "a";
        // string k = "b";
        // string l = "c";
        llOwnerSay((string)llGetFreeMemory());
    }
}</LSL> [[User:LepreKhaun Resident|LepreKhaun Resident]] 13:06, 19 December 2013 (PST)
=== Needed Updates ===
=== Needed Updates ===
Using the script below I found a few unusual things happening. One of them seems to be a change in free script memory at the time of compilation. This script provided the data listed below it.<lsl>integer count;
Using the script below I found a few unusual things happening. One of them seems to be a change in free script memory at the time of compilation. This script provided the data listed below it.<lsl>integer count;

Revision as of 13:06, 19 December 2013

Has anyone tested the new MONO environment for memory usage? It seems its very different from the previous LSO numbers... I think a new section for MONO is needed.--Darwin Recreant 21:21, 4 December 2008 (UTC)

Size of Strings under Question

Unsure of code used by others to determine the size of a local string under Mono but my testing seems to show that a string is approximately 24 bytes + 1 per char. This is the code I'm using with the length of variable "i" such that the addition of one more character causes another page being allocated for memory used. Uncommenting each Test in turn and rerunning it with one additional character in any of the string variables (to show that you are actually at the edge of a page) should show you what I'm finding. Perhaps I'm misinterpreting the results??? <LSL>default {

   state_entry()
   {
       // Test 1, add one char to string for memory jump of a page
       string i = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn";
       // Test 2 - difference of 32 bytes in variable "i"
       // string i = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi";
       // string j = "a";
       // Test 3 - difference of 27 bytes in variable "i"
       // string i = "abcdefghijklmnopqrstuvwxyzabcdefgh";
       // string j = "a";               
       // string k = "b";
       // Test 4 - difference of 26 bytes in variable "i"
       // string i = "abcdefgh";
       // string j = "a";
       // string k = "b";
       // string l = "c";


       llOwnerSay((string)llGetFreeMemory());
   }

}</LSL> LepreKhaun Resident 13:06, 19 December 2013 (PST)

Needed Updates

Using the script below I found a few unusual things happening. One of them seems to be a change in free script memory at the time of compilation. This script provided the data listed below it.<lsl>integer count;

default {

   state_entry()
   {
       llSetTimerEvent(1.0);
   }
   timer()
   {
       llOwnerSay((string)llGetFreeMemory() + " , " + (string)(++count));
       list l = ["", "", "", ""];
       llOwnerSay((string)llGetFreeMemory());
   }
   touch_start(integer detected)
   {
       llResetScript();
   }

}</lsl><lsl>[22:44] EddyFragment Robonaught: Test Begins [22:44] Object: 60664 , 1//Only just recompiled for touch reset. [22:44] Object: 60664 [22:44] Object: 60664 , 2 [22:44] Object: 60628 //Then evens out [22:44] Object: 60628 , 3 [22:44] Object: 60628 [22:44] Object: 60628 , 4 [22:44] Object: 60628 [22:44] Object: 60628 , 5 [22:44] Object: 60628 [22:44] Object: 60628 , 6 [22:44] Object: 60628 [22:44] Object: 60628 , 7 [22:44] Object: 60628 [22:44] Object: 60628 , 8 [22:44] Object: 60628 [22:44] Object: 60628 , 9 [22:44] Object: 60628 [22:44] Object: 60628 , 10 [22:44] Object: 60628 [22:44] Object: 60664 , 1//After a touch reset [22:44] Object: 60628 [22:44] Object: 60628 , 2 [22:44] Object: 60628 [22:44] Object: 60628 , 3 [22:44] Object: 60628 [22:44] Object: 60664 , 1 [22:44] Object: 60628 [22:44] Object: 60628 , 2 [22:44] Object: 60628 [22:44] Object: 60628 , 3 [22:44] Object: 60628 [22:44] Object: 60628 , 4 [22:44] Object: 60628 [22:44] Object: 60664 , 1 [22:44] Object: 60628 [22:44] Object: 60628 , 2 [22:44] Object: 60628 [22:44] Object: 60628 , 3 [22:44] Object: 60628 [22:44] Object: 60664 , 1 [22:44] Object: 60628 [22:44] Object: 60628 , 2 [22:44] Object: 60628 [22:44] Object: 60628 , 3 [22:44] Object: 60628 [22:44] Object: 60628 , 4 [22:44] Object: 60628 [22:44] Object: 60664 , 1 [22:44] Object: 60628 [22:44] Object: 60628 , 2 [22:44] Object: 60628 [22:44] Object: 60664 , 1 [22:44] Object: 60628 [22:45] Object: 60628 , 2 [22:45] Object: 60628 [22:45] Object: 60628 , 3 [22:45] Object: 60628 [22:45] Object: 60628 , 4 [22:45] Object: 60628 [22:45] Object: 60628 , 5 [22:45] Object: 60628 [22:45] Object: 60628 , 6 [22:45] Object: 60628 [22:45] Object: 60628 , 7 [22:45] Object: 60628 [22:45] Object: 60628 , 8 [22:45] Object: 60628 [22:45] Object: 60628 , 9 [22:45] Object: 60628 [22:45] Object: 60628 , 10 [22:45] Object: 60628 [22:45] Object: 60628 , 11 [22:45] Object: 60628 [22:45] Object: 60664 , 1 [22:45] Object: 60628 [22:45] Object: 60628 , 2 [22:45] Object: 60628 [22:45] Object: 60628 , 3 [22:45] Object: 60628 [22:45] Object: 60664 , 1//But this would happen (it seemed to me) after letting the script run a little more before the reset [22:45] Object: 60664 [22:45] Object: 60664 , 2 [22:45] Object: 60664 [22:45] Object: 60664 , 3 [22:45] Object: 60664 [22:45] Object: 60664 , 4 [22:45] Object: 60664 [22:45] Object: 60664 , 5 [22:45] Object: 60628 [22:45] Object: 60628 , 6 [22:45] Object: 60628 [22:45] Object: 60628 , 7 [22:45] Object: 60628 [22:45] Object: 60628 , 8 [22:45] Object: 60628 [22:45] Object: 60664 , 1 [22:45] Object: 60628 [22:45] Object: 60628 , 2 [22:45] Object: 60628 [22:45] Object: 60664 , 1 [22:45] Object: 60628 [22:45] Object: 60628 , 2 [22:45] Object: 60628 [22:45] Object: 60628 , 3 [22:45] Object: 60628 [22:45] Object: 60628 , 4 [22:45] Object: 60628 [22:45] Object: 60628 , 5 [22:45] Object: 60628 [22:45] Object: 60628 , 6 [22:45] Object: 60628 [22:45] Object: 60628 , 7 [22:45] Object: 60628 [22:45] Object: 60628 , 8 [22:45] Object: 60628 [22:45] Object: 60628 , 9 [22:45] Object: 60628 [22:45] Object: 60628 , 10 [22:45] Object: 60628 [22:45] Object: 60628 , 11 [22:45] Object: 60628 [22:45] Object: 60628 , 12 [22:45] Object: 60628 [22:45] Object: 60664 , 1 [22:45] Object: 60628 [22:45] Object: 60628 , 2 [22:45] Object: 60628 [22:45] Object: 60664 , 1//And here again [22:45] Object: 60664 [22:45] Object: 60664 , 2 [22:45] Object: 60664 [22:45] Object: 60664 , 3 [22:45] Object: 60664 [22:45] Object: 60664 , 4 [22:45] Object: 60664 [22:45] Object: 60664 , 5 [22:45] Object: 60628 [22:45] Object: 60628 , 6 [22:45] Object: 60628</lsl> -- Eddy (talk|contribs) 06:01, 2 July 2009 (UTC)

This is interesting. -- Strife (talk|contribs) 18:36, 2 July 2009 (UTC)

Thanks for the confidence boost and I thought so too. If getting inworld is still a problem for you tell me what to run and I'll happily do it for you. Otherwise my tests might be a bit less than useful. Those repeated 60664's are weird though. -- Eddy (talk|contribs) 23:53, 2 July 2009 (UTC)

It seems llGetFreeMemory() does not show true value and is dependent on sim performance (random like) on getting updated. I guess the only way to know true impact of operations and variables can only be tested after many subsequent tries similar to Eddy's method. --Darwin Recreant 08:51, 10 December 2009 (UTC)

I'd say the above observations were due the the random involvement of garbage collection. If you do an llSleep(2.0) or so before accessing llGetFreeMemory() you'll give garbage collection a good chance to get in, and results will be more consistent. But running this code in December 2012 did not show variation for me. So I'd guess this is an obsolete observation and this page can be revised down in size? Omei Qunhua 17:27, 28 December 2012 (PST)

List Storage Requirements (Mono) need updating

It appears that the storage requirements for lists in Mono have changed since this page was written. I plan to change the figures to those experienced in December 2012 as shown on my user page, unless anyone disagrees. Omei Qunhua 17:27, 28 December 2012 (PST)

I would almost be inclined to suggest rewriting the article from scratch. It's an old article which had Mono info bolted one after the fact. -- Strife (talk|contribs) 21:13, 28 December 2012 (PST)


The article talks about datas collected by llGetFreemomry and not llGetUsedMemory . Are the samples collected recently using always this old function ? Shouldn t have we some datas collected by llGetUsedMemory ? -- Miranda Umino 14:21, 16 February 2013 (PST)

Update pending

<lsl> //////////////////////////////////////////////////////////////////////////////// // // Script memory - work in progress // // (c) 1012 // llDeleteSubString( "yepey Resident", llSubstringIndex( "yepey Resident", " " ), -1 ); // // The script won't compile due to previously decalerd variables. // This script will, when finished, replace all of the above. // // Regards, // yepey // // // GLOBAL VARIABLES // -------------------------------------------------------------------- integer int = 0; // 8 float fl = 0.0; // 8 string str = ""; // 22 string str = "a"; // 22 + 2 string str = "\n"; // 22 + 2 key id = ""; // 8 key id = NULL_KEY; // 8 key id = "a822ff2b-ff02-461d-b45d-dcd10a2de0c2"; // 8 vector v = ZERO_VECTOR; // 16 vector v = < 0, 0, 0 >; // 16 rotation r = ZERO_ROTATION; // 16 rotation r = < 0, 0, 0, 1 >; // 16 list l = []; // 44 list l = [ // 44 + o.O

                   0,                                      //    28
                   1.0,                                    //    28
                   "",                                     //    30
                   "a",                                    //    32
                   "\n",                                   //    32
                   NULL_KEY,                               //   102
                   ZERO_VECTOR,                            //    36
                   ZERO_ROTATION                           //    40
                 ];

default {

   state_entry()
   {
       

// LOCAL VARIABLES // ------------------------------------------------------------------------

       integer     int = 0;                                        // 4
       float       fl  = 0.0;                                      // 4
       string      str = "";                                       // 18 +
       string      str = "a";                                      //    2
       string      str = "\n";                                     //    2
       key         id  = "";                                       // 4
       key         id = NULL_KEY;                                  // 4
       key         id = "a822ff2b-ff02-461d-b45d-dcd10a2de0c2";    // 4
       vector      v   = ZERO_VECTOR;                              // 12
       vector      v   = < 0, 0, 0 >;                              // 12
       rotation    r   = ZERO_ROTATION;                            // 16
       rotation    r   = < 0, 0, 0, 1 >;                           // 16
       list        l   = [];                                       // 40
       list        l   = [                                         // 40 + o.O
                           0,                                      //    16
                           1.0,                                    //    16
                           "",                                     //    18 +
                           "a",                                    //       2
                           "\n",                                   //       2
                           NULL_KEY,                               // 90
                           ZERO_VECTOR,                            // 24
                           ZERO_ROTATION                           // 28
                           ];
       
   }
   

}

state examples {

   state_entry()
   {
       
       /* IMPLEMENTATION NEEDED  */
       
   }
   

} </lsl> Joanne Furlough 20:07, 5 May 2013 (PDT)