Global vs Local Variables
|
|
Nalates Urriah
D'ni Refugee
Join date: 11 Mar 2008
Posts: 113
|
05-11-2009 23:30
On the College of Scripting they were talking about local variables nor clearing (freeing memory - memory leak) on function/state exit. Therefore use of globals was the way to go.
I've been looking for a thread discussing that. Didn't find it. Is there one here one can point me too?
Or does someone know what the story is on local variables and memroy release (garbage collection)?
If they are correct and a function/state is repeatedly called with say a bunch of counters (i and x may be) and temporary strings then eventually the script will fail from consuming memory.
_____________________
Nalates Urriah D'ni Refugee - Guild of Cartographers
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-12-2009 00:37
From: Nalates Urriah On the College of Scripting they were talking about local variables nor clearing (freeing memory - memory leak) on function/state exit. Therefore use of globals was the way to go.
I've been looking for a thread discussing that. Didn't find it. Is there one here one can point me too?
Or does someone know what the story is on local variables and memroy release (garbage collection)?
If they are correct and a function/state is repeatedly called with say a bunch of counters (i and x may be) and temporary strings then eventually the script will fail from consuming memory. that would be the assumption, except that I think that returning to a state may simply overwrite the previous values, so it'd be more accurate to say that those variables are preserved, so in essence you're only progressively losing memory space through continuing to new states with new local variables, and reurning to previous states will just reuse the variable spaces that were preserved (much less dire than the original assumption but still not really that good.) ETA: I don't remember any discussion of that in the forum here, but I may have missed it... or not considering most of the deep technical stuff gets tacked on the end of much more basic discussions. Now I thought that MONO did garbage collection on exiting event code(including local variables), so it's possible that only the current events local variables aren't collected on the state change (although it may be possible to set an empty state_exit to force this garbage collection) and if this is the case, that space may or may not get reused...I'm not sure. if the latter is the case then you only need worry about not using local variables in event code that calls a state change, and it may be possible to clear some of that with an state_exit (haven't tested, just guessing)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-12-2009 01:36
Wouldn't it be nice if SL had a forum where we could have more exact information about SL's products and services? A lot of answers in this forum are plain guesses and feelings an roomers 
_____________________
From Studio Dora
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-12-2009 02:42
unfortunately when it comes to how the script VM works, the best we can do is inference (pretty sad given the tools we have) and quotes gleaned from the rare mid-level discussions by LL of how it works.
what little I know of the garbage collection routines in MONO is gleaned from talks and comments from other users that are a little more connected to certain Lindens than most of us.
I couldn't tell you what is or isn't done, although my memory (which is faulty) says it's triggered after event code... but with the problematic nature of how llGetFreeMemory is working (or rather, NOT) in mono, it's hard to test the inference of what it's doing (and almost impossible to know HOW)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
05-12-2009 21:59
From: Dora Gustafson Wouldn't it be nice if SL had a forum where we could have more exact information about SL's products and services? A lot of answers in this forum are plain guesses and feelings an roomers  Well, since the techies who oil the VM don't browse the forums here, perhaps an office visit to the right people might help... who to ask though, Soft, Zero, Babbage, Andrew, Simon? Hard to say who'd be the best to ask, maybe Andrew. In either case, if you ask the right Linden the right question, you can get a pretty straight answer right from the horse's mouth.
_____________________
My tutes http://www.youtube.com/johanlaurasia
|
|
Nalates Urriah
D'ni Refugee
Join date: 11 Mar 2008
Posts: 113
|
05-13-2009 16:14
No one in the scripting groups seems to know for sure. Most of what we have in the Wiki is from users. So, it looks like and office visit is in order. Thanks peeps. Edit: Babbage is the only one that is listed for scripting. His hours are 3AM-4AM SLT Wednesday...  not my time of day. I'll search in-world and see what the others deal with scripting.
_____________________
Nalates Urriah D'ni Refugee - Guild of Cartographers
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-13-2009 18:04
any of the ones johan listed deal with the programming guts (or directly with those that do)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
05-13-2009 18:23
From: Nalates Urriah On the College of Scripting they were talking about local variables nor clearing (freeing memory - memory leak) on function/state exit... /me blinks. That would be a pretty ginormous bug on LLs part. So big I have a hard time believing it. Is this something new? Is it just a rumor?
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!! - Go here: https://jira.secondlife.com/browse/SVC-3895- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-13-2009 19:01
From: Sindy Tsure /me blinks. That would be a pretty ginormous bug on LLs part. So big I have a hard time believing it.
Is this something new? Is it just a rumor? actually it'd be pretty unnoticeable in many cases especially if it's only the event just left on a state change, especially given script sizes..... it might take a very long time to hit that random seeming crash. it's fairly easy to test though, just repeatedly force a state change in two states state entry that makes use of a local variable.... llGetFreeMemory SHOULD be able to at least track the difference in a constantly dropping watermark over a few hundred iterations.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
05-13-2009 19:11
Oh.. It's only state changes? I read it differently.. Never mind.. 
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!! - Go here: https://jira.secondlife.com/browse/SVC-3895- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|