Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
|
08-26-2005 00:16
Hi all
Does anyone have a link to something that explains ( in detail ) a scripts memory usage ?
A few questions that I would like answered would be :
Is the code stored as text or tokenized and are the comments taken into the memory equation. ( Much as I hate it I am willing to sacrifice comments and throw in multi statement lines if this saves me a precious few bytes )
The 16k limit - does that apply to each individual script or to the whole prim ( I have had scripts stop working because I increased the number of items in the content ). I thought to get around the limit by having several scripts in the prim ( list controller, user interface, IO controller etc etc - but had to give the idea up as the increase in content blew my theory out )
Are local variable definitions taken into the whole script requirement's or are they "local" and release their memory on exit from the routine.
A bit away from the topis - lists. Are lists just stored as linked-strings then converted at retrieval time - or is it more efficient to store item keys (long strings) than just the item name. (or is it more efficient to just use a long string and handle the listing functions yourself)
Anyway as I said is there a link to a white paper or something that shows this stuff in detail as try as I might my scripts just keep getting close to being worth while and functionally competent before they trip me up and say you can have either the script or the content - not both.
Thanks In Advance
|
Alex Edo
Insert Brain Here...
Join date: 27 Feb 2005
Posts: 108
|
08-26-2005 02:28
I don't know alot on this but, it's script memory. Not prim memory.
use: llSay(0,(string)llGetFreeMemory());
this will give you the memory in bytes.
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
08-26-2005 03:12
Scripts are stored in both text and compiled bytecode forms. You can use as much comments and long variable names you want, it won't affect the memory your script is using. Each script has 16k of memory for everything, code, constants, variables and heap (for function call contexts and local variable allocation). The heap grows and decreases as the script enters and exits function calls.
Lists are linked strings, so if your inventory object has a name shorter than a key use that instead and save bytes. In some cases it is simpler to grow a big string instead of a list, IIRC you save about 8 to 16 bytes per item this way. If you have fixed-length items, definitely do that. You only lose some functionality for rearranging, replacing, inserting or deleting items, which can be done with the string handling functions anyway.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
|
thnx
08-26-2005 04:05
Thanks
That confirmed some of my assumptions and dispelled others. (Still concerned why a script stopped after an increase in content - will have another look at it)
(As a side note As i understand it the GetFreeMemory function returns what is left out of 16k AFTER the maximum amunt the script HAS used - so if you define a 100 entry list then delete it the reported free memory WILL NOT go down - so this function is a bit of a hit and miss thing and not to be relied on for accuracy)
|