Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Another ? on Linked Msg's

JP Burleigh
Registered User
Join date: 15 Oct 2005
Posts: 11
10-26-2005 07:39
Hello everyone,

I had completed my first scripted object and all was working well when lo and behold I received a Heap error message. In hindsight it is obvious that the length of my single script plus all the data being added will easily overflow my 16kb allocation.

Based on other postings it appears that I can resolve this by partitioning my code into multiple scripts but I am hoping the community can help confirm my assumptions before I begin to refactor my code.

1. Does each script have it's own 16kb allocation?
1a Does this remain true for multiple scripts on a single object?

2. If I have a separate script that handles my linked message calls and within my processing from the main script I set data (via globals in the linked script) will that data be retained for subsequent LM calls. My thinking is that the script comes alive due to its listener when the object is created and that it will be persistent throughout the life of the object.

3. At a high level I am creating a game and in my main script is my state handler, game rules engine and interface. This script will be fairly constant in size (script plus set of constants and data that does not significantly grow).
As players interact with the game I am thinking of passing these activities off to a separate script via a linked message. This can generate a fair amount of dynamic data that I'm hoping will grow in a separate script that has most of it's 16kb available to data. However, I will need this data to be retained until the game engine determines it is time to process the results. At that time I will reset the player data via a linked messgae into the player data script that resets the global variables.
Does this approach to partitioning make sense? will it work? Also, does the new patch make it more likely that latency may bite me in the *ss. Since Im recording players activities via asynchronous calls how likely is it that a players activity will not have been registered in time once the engine tries to process the result? How long should I wait for those threads to complete?

Sorry for the big post, I'm hoping that the detail makes my scenario more understandable.
Thanks for any advice you may have, as a new scripter I have found this forum extremely valuable.

- JP
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-26-2005 08:01
Each script has its own 16KB, including scripts that are in the same prim

Globals stay defined after an event completes (that's the point of globals).

Your approach makes perfect sense :) I think it'll work. The new patch will likely have zero impact on your scripts, but depending on what events you are using to monitor player activity, it may miss something :(

Also, don't use the word "threads" to qualify anything done in LSL, except parallel, seperate scripts. A script is always unithread, and while one event executes all other events triggered just pile in a queue, waiting to be run.
_____________________
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.
JP Burleigh
Registered User
Join date: 15 Oct 2005
Posts: 11
10-26-2005 08:26
Thanks for the info (again) Jesrad, much appreciated. I will work on this tonight and am looking forward to the results.

You're right about usage of the term "threads" and I do recognize that each script is a separate thread but each event within the thread is queued sequentially.

btw, for simplicity sake my current interface for interacting with the object is via dialog boxes/chat/listen. I know its not very efficient but it has been a good way for me to focus on my logic without an explosion of prims.