![notecard giver script second life notecard giver script second life](https://image.slidesharecdn.com/sourcecardsnotecards-130404084435-phpapp02/95/source-cards-note-cards-3-638.jpg)
I’m going to run the profiler, find out how much memory the script uses then set my memory limit to that figure, I wouldn’t advise people do this for production scripts, I’d add some spare capacity, but this gives you an idea on what you can do. Note the caveats there, having the profiler on adds to overheads. There are a few ways of getting an idea of how much memory a script uses but what I’m going to do here is use llScriptProfiler and base my test on the example there. Now the first thing to note here is that I wouldn’t put a for sale script out there using this method, but it gives you an idea of how things work. So let’s look at how we can reduce that using llSetMemoryLimit() However this is a Mono script so it defaults to an upper memory limit of 64kb: Then I make sure there’s a notecard in the contents of the prim and when I touch it, I’ll get a Notecard. LlGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0)) 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): 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. I’ll start by visiting LSL Wiki and going to the llGiveInventory section. In this post I’ll show how this works with a very basic script, a notecard giver.
![notecard giver script second life notecard giver script second life](https://slm-assets.secondlife.com/assets/6196310/view_large/Snapshot_010fav.jpg)
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.Īnyway, 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. 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.