joniveehernandez Posted January 23, 2013 Share Posted January 23, 2013 Hi guys I'm developing a script that detects if the agent is using high memory usage. Ofcourse I want to set my memory value that determines the critical level. Can you give me an idea if what's the usual memory usage normal memory usage and too high memory usage? -Thanks! Link to comment Share on other sites More sharing options...
Dora Gustafson Posted January 23, 2013 Share Posted January 23, 2013 The wiki has this about memory In the first section you find links to different LSL functions used to manage memory These function pages have links to even more functions Have fun :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
Ela Talaj Posted January 24, 2013 Share Posted January 24, 2013 Script memory usage depends not that much on a code but on types and quantity of data the code operates upon. For example, a script may include 10-12 lines of code for a couple K of memory but would operate on a large list containing 20K of data. Do not forget that in LSL all function arguments are objects passed by value as there is no concept of pointer. That includes LSL methods themselves so for instance every time when llListFindList(mylist, [findthis]) is called it creates a copy of the original mylist so the memory usage increases while the method is executed. This considered, terms normal memory usage and usual memory usage are rather meaningless unless one identifies a specific application. Link to comment Share on other sites More sharing options...
joniveehernandez Posted January 25, 2013 Author Share Posted January 25, 2013 Thanks Ela for pointing also the llListFindList() function. For example if Imy list has a value the uses 10KB of memory. Upon execution it creates another copy of 10KB right? But does it affect the script maximum size of 65536 Bytes? Link to comment Share on other sites More sharing options...
LepreKhaun Posted January 25, 2013 Share Posted January 25, 2013 Regardless of lists or not, if it's mono, it uses 64k unless reduced with llSetMemoryLimit(). This has mainly to do with the way the stack and heap are allocated. If your concern is with the load an agent is using, your main concern would be with the number of scripts each has (keeping in mid that inactive scripts in the world still have memory requirements!) A limit of 40-50 scripts per agent may not be unreasonable in some circumstances (wargames, classrooms with over 20 avatars, etc). Here's a link that may be of interest to you - http://www.sluniverse.com/php/vb/script-library/52486-simple-sensor-based-avatar-script.html Link to comment Share on other sites More sharing options...
joniveehernandez Posted January 25, 2013 Author Share Posted January 25, 2013 Still confusing regarding memory, alright here's a one scenario: I got 2 buttons that add and remove agent name from a list variable lets call it "guests", I add and remove via textbox. If I add agent name my list will be updated with the new agent name, in that case the memory allocation will be reduce. and if I remove that agent name from that list the memory allocation will goes up back. in order to test of changes of memory I put a llGetFreeMemory() in touch event to see the changes of memory. Test Result No.1: when adding new agent name it lessen the free memory. Test Result No.2: when removing an agent name from that list the memory doesn't change. Can you give me a clear explanation to it?, remember this is only a scenario. Why I'm doing this is so I can decide what will be the maximum guests I can store in my script. and 1 character is 1 byte right? if i will allow 500 slots for my guests where username is maximum of 63 characters that means 500 username multiply by 63 characters will result to 31500 bytes? correct me if I'm wrong guys because this is only a theory of mine. Link to comment Share on other sites More sharing options...
Qie Niangao Posted January 25, 2013 Share Posted January 25, 2013 LepreKhaun wrote: Regardless of lists or not, if it's mono, it uses 64k unless reduced with llSetMemoryLimit(). This has mainly to do with the way the stack and heap are allocated. If your concern is with the load an agent is using, your main concern would be with the number of scripts each has (keeping in mid that inactive scripts in the world still have memory requirements!) In practice, the number of scripts is nearly as good a metric as the total script memory use, but not quite for the reason given. It's more complicated than that. For starters, the actual memory used by a Mono script is only limited to 64k or any lower ceiling imposed by llSetMemoryLimit. A Mono script uses only whatever memory it needs, not the amount to which it is limited, but all external memory usage metrics are based on those limits. There's no actual allocation of memory corresponding to the limit; rather, the limit is more like a quota. (In contrast, a script compiled to LSL instead of Mono will always take up 16k regardless of how much memory it actually needs.) The thing is, all this external measuring and internal setting of Mono memory limits was originally intended to be used in conjunction with a limit imposed on parcels (per sq.m.) and avatars. If such land/avatar limits were in place, it would be incentive for scripters to set their script memory limits close to what the script actually uses, thus allowing the script to be used when the land/avatar limit is tight. Because there are no land/avatar limits, however, there's little reason to reduce a script's memory limit: it doesn't reduce the actual memory footprint (as explained above); indeed, just adding the call to llSetMemoryLimit() adds some (tiny) amount of actual memory use with no corresponding benefit. Hence, for very good reason, hardly any scripts use llSetMemoryLimit(), and so just counting the scripts is nearly as accurate as summing their memory limits. In fact, because the average Mono script is much smaller than the default 64K limit that practically all of them report, just pretending that they're all 16K might be on average more accurate than summing their bogus limits. Link to comment Share on other sites More sharing options...
Qie Niangao Posted January 25, 2013 Share Posted January 25, 2013 and 1 character is 1 byte right? Nope. Especially not in Mono strings, which use UTF-16 encoding. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted January 25, 2013 Share Posted January 25, 2013 What consitutes "too high memory usage" is a bit of a contentious topic, to say the least. You might want to take a look at a discussion we had about this over at SLU last year. As you'll see, experienced and skilled scripters have markedly different views on the subject, as do people who don't know much about it, and tempers sometimes get frayed. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now