Difference between revisions of "User:Becky Pippen/Script Memory Limits"

From Second Life Wiki
Jump to navigation Jump to search
(Preliminary, for upcoming script memory limits)
 
m (in anticipation of script memory limits)
Line 3: Line 3:


Don't panic. See this [[User:Becky_Pippen/Memory_Limits_FAQ|FAQ]], then see the strategy and checklist below and do what you need to do.
Don't panic. See this [[User:Becky_Pippen/Memory_Limits_FAQ|FAQ]], then see the strategy and checklist below and do what you need to do.
(This is an incomplete page in progress.)


==Strategy==
==Strategy==
Line 11: Line 9:
first before tweaking individual lines of code. Sorry, I'm not impressed if you save
first before tweaking individual lines of code. Sorry, I'm not impressed if you save
a dozen bytes through some clever rearrangement
a dozen bytes through some clever rearrangement
of a formula here or a statement there. First see if you can whack off
of a formula here or a statement there. First see if you can eliminate entire scripts or whack off
''thousands'' of bytes all at once by using a different approach or algorithm,
''thousands'' of bytes all at once by using a different approach or algorithm,
or by removing that one memory-hungry feature, or by using a different
or by removing that one memory-hungry feature, or by using a different
data storage format.
data storage format. Then review the checklist below for more ideas.


==Checklist==
==Checklist==


# Measure First: Have you used [[LlGetFreeMemory|llGetFreeMemory()]] to measure how much memory your script uses? Do you know how much of that is program code and how much data? If not, learn more about [[User:Becky_Pippen/Measure_Script_Memory_Usage|measuring memory usage]].
# '''Memory''' - For help measuring the memory your script uses, see [[User:Becky_Pippen/Measure_Script_Memory_Usage|this page]].
# Multiple Scripts: Does your scripting project use multiple scripts? If so, determine why:
# '''Requirements and goals''' - Do you know how efficiently your data currently uses memory? Do you know how much improvement is possible? For suggestions, see [[User:Becky_Pippen/Memory_Efficiency|this page about measuring information content and memory efficiency]].
#* If it's a resizer or retexture script, or any set of scripts that update child properties in a link set simultanously, see [[User:Becky_Pippen/New_LSL_Functions|the new LSL functions]].
# '''Scripts in child prims''' - If your object uses multiple scripts to detect changes in child prims, or for resizing or retexturing all the prims in a linkset (like some hair or shoes), see [[User:Becky_Pippen/New_LSL_Functions|the new LSL functions]] to reduce this to a single script.
 
# '''Keys/UUIDs''' - If your script needs to store long lists of keys (UUIDs) of any kind, see [[User:Becky_Pippen/Key_Storage|these suggestions for key storage]].
(Page in progress -- more to come soon...)
# '''Numeric data''' - If your script needs to store long lists of numeric data, see [[User:Becky_Pippen/Numeric_Storage|these suggestions for storing numeric data]].
# '''Strings/Text''' - If your script contain a large number of strings for error messages or help text, perhaps in multiple languages, see [[User:Becky_Pippen/Text_Storage| these suggestions for storing text data]].
# '''Name/UUID identities''' - Does your script need to remember lots of avatar names or keys? This is like an update server or an inventory item giver that is designed to give an item once to any one avatar. If so, consider [[User:Becky_Pippen/Hashing|storing hashes]] of the avatar keys concatenated in a long string instead of storing keys or names in a list.

Revision as of 15:59, 30 December 2009

Script Memory Limits

Oh No! LSL script memory limits are coming! What to do?

Don't panic. See this FAQ, then see the strategy and checklist below and do what you need to do.

Strategy

To reduce script memory usage, start with the big items first before tweaking individual lines of code. Sorry, I'm not impressed if you save a dozen bytes through some clever rearrangement of a formula here or a statement there. First see if you can eliminate entire scripts or whack off thousands of bytes all at once by using a different approach or algorithm, or by removing that one memory-hungry feature, or by using a different data storage format. Then review the checklist below for more ideas.

Checklist

  1. Memory - For help measuring the memory your script uses, see this page.
  2. Requirements and goals - Do you know how efficiently your data currently uses memory? Do you know how much improvement is possible? For suggestions, see this page about measuring information content and memory efficiency.
  3. Scripts in child prims - If your object uses multiple scripts to detect changes in child prims, or for resizing or retexturing all the prims in a linkset (like some hair or shoes), see the new LSL functions to reduce this to a single script.
  4. Keys/UUIDs - If your script needs to store long lists of keys (UUIDs) of any kind, see these suggestions for key storage.
  5. Numeric data - If your script needs to store long lists of numeric data, see these suggestions for storing numeric data.
  6. Strings/Text - If your script contain a large number of strings for error messages or help text, perhaps in multiple languages, see these suggestions for storing text data.
  7. Name/UUID identities - Does your script need to remember lots of avatar names or keys? This is like an update server or an inventory item giver that is designed to give an item once to any one avatar. If so, consider storing hashes of the avatar keys concatenated in a long string instead of storing keys or names in a list.