"Rea" <Re*@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
Hey eb
can this be the reason for huge memory expansion ?
Doesn't this script free memory of the object it had created?
sub createCOMobject()
set obj1 = createObject("object1")
dim flag = 1
useObject flag,obj1
end sub
----------------------------------
sub useObject (flag, byRef obj1)
...
set obj1 = Nothing
end sub
Thanks for your attention
Rea
I've just posted this answer in the components group. Please don't
multipost.
Setting an object variable to nothing does not free memory.
Assigning a new value (whatever it is not just nothing) to variable will
cause the release method of the any currently held reference to be called
before the reference is replaced by the new value.
Calling release on an interface reference (commonly known as an object
variable) causes the object to decrement an internally held count of the
number of references that have been made. When this count reaches zero then
it is the object's responsibility to deallocate any memory or other
resources it may be holding.
obj1 is passed byRef (the default mode in VBScript BTW) so the assigning of
Nothing to obj1 is applied to the variable of the same name in the
createCOMobject procedure. Since this is the only reference being held the
internal reference count of the object drops to zero and the object should
destroy itself at this point.
However without the line assigning nothing to the obj1 variable the obj1
variable is destroyed when the procedure createCOMobject returns, at this
point any reference currently held in obj1 has it's release method called.
Hence in this case the assignment of nothing is superflous.
HTH,
Anthony.