I’m going to talk here about a relatively new scripting function, llSetMemoryLimit, this may not work the way one thinks it does, but it basically sets the upper memory limit your script can use. I’m far from being a scripting expert but this looks like a function that people should get used to using where they can, even if it might not actually save memory for a sim the way we may think it should, I’m not sure how the server handles the space.
Anyway, when you create a new script, if Mono is ticked, it has an upper memory limit of 64kb, if you don’t compile the script as Mono, it compiles as LSO, and that has an upper memory limit of 16kb, with LSO it’s a hard rule, all LSO scripts have an upper limit of 16kb, llSetMemoryLimit won’t work with LSO, with Mono however you can set a lower limit. In this post I’ll show how this works with a very basic script, a notecard giver.
I’ll start by visiting LSL Wiki and going to the llGiveInventory section. LSL Wiki isn’t as up to date as the LSL portal but I often find the discussions and examples on LSL Wiki more helpful. So all I want is a notecard giver, I rez a prim, go to the contents tab, click new script, get the default hello world script, delete everything and replace it with this (with apologies for the horrid coding style):
Then I make sure there’s a notecard in the contents of the prim and when I touch it, I’ll get a Notecard. However this is a Mono script so it defaults to an upper memory limit of 64kb:
So let’s look at how we can reduce that using llSetMemoryLimit()
Continue reading »