Re: what is the best way to 'unset' a variable
Re: what is the best way to 'unset' a variable
- Subject: Re: what is the best way to 'unset' a variable
- From: Arthur J Knapp <email@hidden>
- Date: Sat, 23 Mar 2002 14:16:07 -0500
>
Date: Sat, 23 Mar 2002 00:07:22 -0800
>
From: Bill Hoffman <email@hidden>
>
Subject: Re: what is the best way to 'unset' a variable
>
now I've got a temp variable (or I could have several of them) with the
>
contents of an entire file in it hanging around that I no longer need or
>
want. I was of the impression (apparently a wrong one)
???
>
... that 'unsetting'
>
this temp variable once its useful life is over during the run time of
>
the script would free up memory or otherwise contribute to efficiency in
>
some way other than just anal tidiness, particularly if the variable(s)
>
in question are huge.
Yes, that's correct. If a variable contains an *exceptionally* large
piece of data that is pushing the script to it's memory limits, and
you need to work with other exceptionally large pieces of data, and
you no longer need the first piece of data, then of course *clearing*
the data will free up available memory.
set x to GetMy10MbTextFile()
set x to missing value --> free up 10 Mb of memory
>
I was also thinking along the lines of something like a script object
>
'destructor' function (just clearing a script object variable outright)
>
for the same reasons.
There is no need for a destructor function, just like any other
value in AppleScript, once no variable is pointing to it, it's
memory is freed:
script o
...
end script
set o to missing value --> "o" no longer points to the script
Mind you, this isn't an issue that comes up very often in AppleScript,
simply because it is rare for a scripter to be manipulating large pieces
of "vanilla" data within AS itself, (as opposed to simply working within
application tell statements, where the application is holding all of the
data, and the script is just sending AppleEvents to that data).
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://mtlab.ecn.fpu.ac.jp/scripting/Jcode_osax.html>
on error number -128
end try
}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.