Jump to content

About Memory Usage


joniveehernandez
 Share

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

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

Recommended Posts

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

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

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


LepreKhaun wrote:

Regardless of lists or not, if it's mono, it uses 64k 
 unless reduced with 
(). 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

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

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

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
 Share

×
×
  • Create New...