
I propose that that LL implement better tools to allow our scripts to utilize the memory they do have to better effect.
Currently, the only way to perform intra-state communication, other than by passing values, (not always possible in an event-driven language such as this) is to declare global variables. The problem with is is a big one, with a few facets.
Global variables are semi-permanent. The memory they consume will not become free until the script is re-written. If you only need a variable for one particular state, the memory is wasted while the script is in the others states.
There is a wholistic solution to this:
1. Implement an Avanced and Normal mode to the LSL editor. The toggle to advanced mode should be non-obvious (such as in the tools drop down of the main viewer, so that it cannot be accidentally enabled. Additionally, attempting to enable it will illicit the dialog, "You are attempting to enable ADVANCED mode. Doing so will greatly increase the ability for something to go wrong in your script. If the terms DMA and Case switch don't roll off of your tongue like the name of an old friend, you may wish to press "CANCEL" and remain in normal mode."
2. Allow the declaration of variables WITHIN the scope of a state, in both normal and advanced mode. It fits right alongside function-scope variables, and shouldn add additional complexity to the normal user. This would allow a state change to free up the memory used by state-scope variables.
This solves the problem of infrequently-used states hogging all the memory.
3. Allow for a sort of virtual Dynamic Memory Allocation in advanced mode. I realize that we wont be able to address actual parts of the memory on the simulator, however we can emulate this, by splitting up each script's 16k chunk into its own address range.
2. Allow the declaration of variables WITHIN the scope of a state, in both normal and advanced mode. It fits right alongside function-scope variables, and shouldn add additional complexity to the normal user. This would allow a state change to free up the memory used by state-scope variables.
This solves the problem of infrequently-used states hogging all the memory.
3. Allow for a sort of virtual Dynamic Memory Allocation in advanced mode. I realize that we wont be able to address actual parts of the memory on the simulator, however we can emulate this, by splitting up each script's 16k chunk into its own address range.
Implementing all three would be a nearly complete solution. Hopefully the warning and non-obvious enabler for advanced mode would prevent normal users from being uneccesarily frustrated by trying to use Dynamic Memory Allocation.
DMA (Dynamic Memory Allocation) would allow events and states to communicate between each other on an as-needed basis, with minimal overhead. By creating global pointer variables which are relatively small, global variables would only occupy their full memory footprint when actually in use.
For those unfamiliar with the terminology, DMA involves the use of a special "pointer" type variable that stores the address (just what it sounds like, the reference to a location) of a place in memory. Then, using other functions, you are able to make that address actually contain something, nothing, or even enter a state of near-nonexistence. (Meaning, though the memory spot exists, it stores nothing, not even information as to what type of information it should be storing. Normally variable always remember what type they are, even if they are set to zero, NULL_KEY, ZERO_ROTATION, etc.)
It is also important to understand that the language SL is written in natively supports these features. Developing the tools would be less "creating them from scratch" and more "bringing them to the surface."
In summary, increasing total memory allocation for each script is a political issue that is difficult to find a comprimise on, and one which the Lindens are unlikely to budge on in the near future. HOWEVER, adding the tools to allow us to more efficiently manage the memory we do have would bring much of the same benefit of increased memory allowance, without the increased demand on finite resources. Presumably, the only cost involved would be in development time for the tools.
Questions? Comments? Anyone? I'm sure I glossed over or missed alot that I should have included. I will edit as I think of things/things are suggested!
). I would love to see better bulk-data handling tools where much of the storage could be handled in "data files" in my object's inventory, rather than within the 16K address space of the script.