Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Transferring Lists and Memory Use?

Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
01-29-2006 18:47
Hello,

Hoping for an answer to a question regarding memory usage in a script that transfers a list to another script via link message.

If you have Script A that contains a list, and for that particular script, memory is a concern as you want that list to be able to hold as many entries as possible.

If you need to transfer that list to another script using a link message....

Which is the better way to do it....transfer the list entry-by-entry...transferring each 'row' in the strided list with a link message and have the receiving script 'rebuild' that list piece by piece as it receives the information...or....to transfer the entire list to the receiving script in one big chunk by dumping the entire list to a string?

What I'm wondering about is the way memory works with regards to this. If Script A may well be pushing the storage limit with its list.....will the script need a ton of free memory in order to transer that list in one big string....thus forcing you to transfer it one little piece at a time.....or will the size of the string being transferred via the link message not matter with regards to memory limits...thus allowing you to transfer it in one big chunk.

Thanks in advance!
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
01-29-2006 19:01
From: Cyrus Odets

What I'm wondering about is the way memory works with regards to this. If Script A may well be pushing the storage limit with its list.....will the script need a ton of free memory in order to transer that list in one big string....thus forcing you to transfer it one little piece at a time.....or will the size of the string being transferred via the link message not matter with regards to memory limits...thus allowing you to transfer it in one big chunk.


LSL is, unfortunately, a pass-by-value language. Assuming a simple scenerio - you pass llDumpList2String the entire list, and it returns a string to you. You're going to need enough memory to handle that potentially large string. Im a little hazy on the details of how memory works in reguards to passing information to API (ll) functions, but if intuition serves (which it often doesnt), you're also going to need enough memory for a second copy of the list (that gets passed to llDumpList2String) and a second copy of the resulting string (that gets passed to llMessageLinked). Someone please correct me if Im wrong. :D (Paging Strife Onizuka, bytecode master...Paging Strife Onizuka....)

All-in-all, passing it a stride at a time, or even an element at a time may be less memory intensive, but much slower. Cest' la vie - CPU tradeoff for this memory optimization. :p
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
01-30-2006 18:09
Thanks for the answers Chris :)

What you explained makes alot of sense and explains alot of what I've been seeing in my own testing. For the particular script I'm working on, performance isn't an issue so passing just a stride at a time isn't an issue as much as the storage I'd lose by passing the entire list and having SL make multiple copies of it.

Thanks again!!!! You're help is always appreciated :)