Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script Memory Conservation

Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
07-30-2004 06:54
I am just about finished with my latest project and I am starting to hit my memory limits. What exactly can I do to conserve memory? Do comments count against the total? Do variable name lengths count against the total? Any pointers would be helpful.
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
Re: Script Memory Conservation
07-30-2004 07:15
From: someone
Originally posted by Al Bravo
I am just about finished with my latest project and I am starting to hit my memory limits. What exactly can I do to conserve memory? Do comments count against the total? Do variable name lengths count against the total? Any pointers would be helpful.


Comments don't count.

Variable name lengths used to count, but they don't anymore.

Try to reduce your number of global variables. If you can't, remember that rotation variables allow you to store 4 floating point values in them, providing some savings.

Review whether or not some of your global variables are necessary. The use of multiple States may simplify your design, and remove the need for some of those global variables. Some global variables may not be necessary, as they may be better off used as local variables in an event handler.

If you have a lot of repetitive code in your project, maybe consider combining the repetition into your own, custom, global functions.

When all else fails, split your project into multiple scripts. Use Linked Messages to talk between them. In my Touring Balloon, there are about 6 core scripts that make up the system. Each script is dedicated to a particular major task of running the "ship", as one big script would be a)hard to manage, and b)wouldn't fit in the memory limitations.
_____________________
Adam Marker
new scripter
Join date: 2 Jan 2004
Posts: 104
data size reference?
07-30-2004 07:24
I am starting to face some space issues as well. One thing that would help would be to know how much space things take.

There used to be a reference in the old script forum which included the space needed for each data type. I cannot find it now. Does anyone have a link, or could it be reposted?
Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
07-30-2004 07:47
Good info Hank - Thanks. After analyzing it, I guess I have to split out a whole major set of functions to yet another prim. I already have 7 others.

Can't we just have 32KB? Please........ :)
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
07-30-2004 07:51
From: someone
Originally posted by Al Bravo
Good info Hank - Thanks. After analyzing it, I guess I have to split out a whole major set of functions to yet another prim. I already have 7 others.

Can't we just have 32KB? Please........ :)


You can have up to 255 scripts in a single prim!
_____________________
Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
07-30-2004 15:51
Hank, that was also helpful. But I must say, splitting that much code into separate scripts and adding the appropriate link messages to transfer 'global' variables was painful. And, I'm not sure if I didn't end up with more code due to all the link message statements. Oh well... at least now it might have a chance of being completed.
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
07-31-2004 07:01
From: someone
Originally posted by Al Bravo
Hank, that was also helpful. But I must say, splitting that much code into separate scripts and adding the appropriate link messages to transfer 'global' variables was painful. And, I'm not sure if I didn't end up with more code due to all the link message statements. Oh well... at least now it might have a chance of being completed.


You do end up using more memory, and enivitably more server resources. This is why we need more script memory! :)
_____________________
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
07-31-2004 07:13
This probably won't help you Al, since it sounds like you're deep into your project already, but when I write scripts, I try to keep each individual script as short and as simple as possible.

You're much better off, especially when it comes to debugging your code, if everything is modularized. Try to segment your script into some basic "functions" (functions in the sense of things that need to be done, not functions in the sense of an LSL function), and have a script for each.

Yes, the link_message overhead can be a pain to deal with sometimes. But the ease of scripting that comes with modularity more than out-weighs this in most cases.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Alondria LeFay
Registered User
Join date: 2 May 2003
Posts: 725
08-01-2004 10:28
Depending what the functionality of the script is, and what type of data it is storing, a possibility is to ship some of the data to an off world source via llEmail or a RPC setup. While it does require a bit of time to do a round trip retrieval of data, I have found it to be at least as fast as dataserver calls.
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
08-01-2004 11:23
You can send/recieve messages using llSet* & llGet*; if you cannot use the event-driven linked messages. :)

-Adam
_____________________
Co-Founder / Lead Developer
GigasSecondServer