Doug L,
You are correct. Once the variable goes out of scope then it is
automatically cleaned up. So all variables that get defined in a sub or
function will automatically be cleaned up when the sub or function exists.
Also, if you have a variable set to an object and you reassign it to a
new object then the old object is automatically cleaned up for you.
If you leave variables defined and you shut your script down then
Window-Eyes will take care of it for you.
But as you mentioned, if you have a global variable set to an object
and you don't need that object any more then it makes sense to set your
variable to nothing to free up that object. Otherwise it will be
allocated until your script shuts down.
Doug
On 10/20/2010 12:52 PM, Doug Lee wrote:
Just to clarify for newer scripters: My understanding is that it's
good to set global objects to Nothing when you're done with them, but
not necessary to do that for local variables in a sub or function,
because they go away automatically when the sub or function exits.
If I'm wrong about this for VBScript, please let me know. Or
Javascript for that matter.
On Wed, Oct 20, 2010 at 12:39:42PM -0400, Aaron Smith wrote:
On 10/20/2010 12:06 PM, J.J. Meddaugh wrote:
doesn't leaving the hotkeys in memory pose memory issues, etc? I
thought it was a best practice to clean up as much as possible.
When we talk about cleaning up after yourself, that typically refers
to creating or storing objects, and then removing references to them
when those objects are no longer being used. For example, it would be
good practice in your sub to set your win variable to Nothing when
you're done with it. That being said, Window-Eyes will take care of
freeing up memory taken up by your script when your script exits.
But whether or not you use the filter by parameter in RegisterHotkey
comes down to how utilitarian you want to be. The filter parameter
method is most certainly acceptable; that's why it's there. Hot keys
in memory, even when they're not being used, add up to a negligible
amount of overhead.
Aaron
--
Aaron Smith
Product Support Specialist * Web Development
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.