Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

script crashing

October Brotherhood
Registered User
Join date: 24 Jun 2005
Posts: 70
11-09-2005 09:50
i'm working on a little puzzle game. i'm making use of some lists in it. i keep getting stack errors and my script stops. is there a limit on the length a list can have? is there a limit to the number of lists you can have in a script? i'm not sure exactly what is causing the issue, i'm just kind of guessing it has something to do with my list vairables. i've never had a script dump on me like this before. what are some common scenarious that would cause this?
Gurgon Grumby
Registered User
Join date: 2 Dec 2004
Posts: 24
11-09-2005 10:12
Script Memory; a script has 16 k of total memory for all of the code and stored infromation, including lists. A script has enough memory to store somewhere in the ballpark of 100 keys and minimal additional code. Put llOwnerSay((string) llGetFreeMemory()); somewhere recurrent in the script to watch the memory usage. You might have to break the script into multiple scripts and use link messages to accomplish what you want.
October Brotherhood
Registered User
Join date: 24 Jun 2005
Posts: 70
11-10-2005 10:02
thank you for your thoughts. i've already split it up quite a bit, but i'll try spreading the workload out a little more. it doesn't seem like i'm asking it to do all that much, given some of the more complex things i've seen in the game. the script is fairly long though.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
11-10-2005 10:17
Code takes up a lot more memory than you'd think it should. Lists are absolutely horrible about storage efficiency... each list item takes several times the storage space of a set of independent variables of the same types. The nastiest thing is that hardcoding in a long list of data (as you might need to do in a game) takes _double_ the memory: once to store the list in the compiled code, and once to actually store it in memory when you're running the script. All of this means that it's very easy to run out of memory very quickly for complex projects like games.
October Brotherhood
Registered User
Join date: 24 Jun 2005
Posts: 70
11-10-2005 13:57
thanks :) all of this info helps
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
11-11-2005 22:58
From: Lex Neva
Code takes up a lot more memory than you'd think it should. Lists are absolutely horrible about storage efficiency... each list item takes several times the storage space of a set of independent variables of the same types. The nastiest thing is that hardcoding in a long list of data (as you might need to do in a game) takes _double_ the memory: once to store the list in the compiled code, and once to actually store it in memory when you're running the script. All of this means that it's very easy to run out of memory very quickly for complex projects like games.


If you create two lists, one for name and one for key of the name, and then start a for loop to add that name and key to the lists until it runs out of memory, you will end up with approximately 128 names and keys. This shows that even with the most minimal of code, lists take up a huge amount of memory. A good sized script will take up between 4 and 6 thousand bytes of memory just for the code itself. Add some lists to that and you run the risk of running out of memory very quickly.

Having "database" scripts is a real pain in the butt too... really need to get some sort of storage happening for scripting. A "notecard" can't be created or written to using a script because of asset server issues and the like but a special type of text/note file that can ONLY be accessed by the script would be possible and while not a perfect solution would definitely ease a lot of these problems.

By having to create split scripts just for data storage, the amount of server load grows exponentially so the 16kb limit is really not a wonderful idea without some kind of internal data storage. I'd place it on the voting page if I thought it would do any good but I've seen alot of ideas that would be of great benefit sit on there for months on end with hundreds of votes, never see the light of day... so I won't waste my time with that.