Jump to content
Crystarx

Stack vs Event Queue

You are about to reply to a thread that has been inactive for 192 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

1 hour ago, Rolig Loon said:

Of course, in this forum and its previous incarnations going back to at least 2007 (when I entered SL and first became aware of the forum) we have always had a sticky thread with handy advice and discussion about LSL challenges.  We have five of them at the top of the Scripting forum right now, in fact, and the moderators have been very responsive to our requests when we have asked them to sticky things of general interest.  I think a blog is a great idea, especially if it means that Rider, Kyle, and others in the Linden Lab basement would participate, but I hope we continue to keep useful tutorials and stuff in our sticky threads too.

agree with the sticky

a way it could be done is that Rider etc do the tuts as Knowledge base articles.  Then a sticky for Knowledge Base articles could be at the top of Scripting sub-forum. When a new KB article is available then it could be added as a new post in the sticky

to avoid having the sticky end up cluttered with our (resident) comment posts then only KB article links are able to be posted in the thread.  When we do want to comment/question an article we can start our own thread, citing the KB article

 

 

  • Like 1

Share this post


Link to post
Share on other sites
20 minutes ago, VenKellie said:

oh god dont use while for looping, that just causes you to write more lines of code which adds to the stack size.

AND FOR THE LOVE OF MEMORY! dont use // comments and minimize your code as much as possible.

 

In general, lines of code and comments have no impact on stack usage in the program. Although, larger programs (with more instructions) will produce more bytecode and reduce the amount of memory available to the stack and the heap. Comments are not compiled into the bytecode at all. 

  • Like 1
  • Thanks 4

Share this post


Link to post
Share on other sites
47 minutes ago, VenKellie said:

oh god dont use while for looping, that just causes you to write more lines of code which adds to the stack size.

and as for what everyone else says, use and delete out of the memory as quickly as possible and store least amount of string characters as possible to avoid the stack heap warning.

AND FOR THE LOVE OF MEMORY! dont use // comments and minimize your code as much as possible.

What's your next tip? Keep variable names as short as possible?

Even if what you think was fact, you should read a book or two on "premature optimization."

Share this post


Link to post
Share on other sites
1 hour ago, VenKellie said:

dont use while for looping, that just causes you to write more lines of code which adds to the stack size.

dont use // comments and minimize your code as much as possible.

on the second

if by don't use comments you mean the source file is smaller when comments are not used then that is true. Comments tho don't use any compiled runtime memory

edit: What Rider said


on the first

under LSO there are memory differences when coding loops. Which I won't get into here as the wiki has lots of examples of LSO performance coding tweaks

under LSL Mono then runtime memory-wise it doesn't matter whether we use WHILE, DO WHILE or FOR

CIL pre-processors (incuding LSL Mono) are smart enough to resolve to the same CIL loop construct, all the different ways the coding language can be used to write a loop

whichever loop method we choose to code in LSL Mono, is more a stylistic choice than an operational/performance choice

3 scripts that do the same thing. 1 commented, 2 not. Showing the different ways to code a loop in LSL Mono. Using the same parameter style so to focus on the looping construct memory consumption. When Saved then all 3 report the same

default
{
    state_entry()
    {
        list this;  // this is a list
        integer i = 10; // set i to some value
        while (~--i)
        {
            // add current value of i to this list
           this += [i];    
        }
        
        // get used memory
        integer mem = llGetUsedMemory();
        
        // tell us the values in chat
        llOwnerSay((string)mem + "," + llList2CSV(this));
        // when i = 10, the values should on Save be 4160,9,8,7,6,5,4,3,2,1,0  
    }
}
default
{
    state_entry()
    {
        list this;
        integer i = 9;
        do
        {
           this += [i];    
        } while (~--i);
        
        integer mem = llGetUsedMemory();
        
        llOwnerSay((string)mem + "," + llList2CSV(this));
    }
}
 

 

default
{    
    state_entry()
    {
        list this;
        integer i = 9;
        for (i; ~i; --i)
        {
           this += [i];    
        }
        
        integer mem = llGetUsedMemory();
        
        llOwnerSay((string)mem + "," + llList2CSV(this));
    }
}

 

Edited by Mollymews
  • Like 4

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 192 days.

Please take a moment to consider if this thread is worth bumping.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...