I understand that there are many dark corners and details to this issue, but
I'mmainly concerned with the simple scenarios exemplified below:
I'm writing a function (that may be called hundreds of times per day) that
uses a recordset object to look up some data. I'm just returning a string
value from the function, not any objectreferences. All variables in the
procedure are local-to-the-procedure in scope. If one of those variables is
a recordset, will it automatically be "set to Nothing" when it goes out of
scope (i.e. the procedure finishes) or do I have to manually do a
Set<variable>=Nothing ?.
I want to do the right thing to keep memory "clean and tidy", but I don't
want to have (lots of?!) Set <variable>=Nothing statements which are
functionally redundant.
Please help me with the straight scoop on this basic situation. TIA
Bill Berry
Steve
In article <OVRR6fBX#GA.233@upnetnews03>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
IMO, always set to nothing, if you hit the problem where the ROT isn't
cleared properly it's the devils own job finding where it's happening, far
easier in the long run to get in the habit of removing the objects yourself.
Bill Berry wrote in message ...
"Microsoft has promised that VBA will always free up object variables and
all resources associated with them when they go out of scope, and that
therefore you do not strictly need to do this. Thus, if you trust Microsoft
that much, never bother to close or set to nothing and everything will be
peachy.
If you believe there may be one or more bugs in a feature that Microsoft has
implemented, you may decide it is in your best interest to explicitly close
what you open and always set object variables to nothing, without exception,
just in case one of these bugs would keep Access from being able to close or
would tie up system resources while your app is running. Its up to you."
Maybe people will listen to it this way? :-)
Michael
Terry Kreft <terry...@mps.co.uk> wrote in message
news:7arq84$aae$1...@gate.mps.co.uk...
Michael Kaplan wrote in message ...
Michael
Keri Hardwick <ke...@sprintmail.com> wrote in message
news:7arthc$8i6$1...@ash.prod.itd.earthlink.net...
--
Lyle
Michael Kaplan <mic...@spamless.trigeminal.com> wrote in message
news:uLgaFdnX#GA.226@upnetnews05...
Abbot Cooper
cooper_N...@mediaone.net
(remove "_NoSpam_" from address when sending)
Michael Kaplan wrote in message ...
- Rebecca
Abbot Cooper <cooper_N...@mediaone.net> wrote in message
news:7asdiv$bce$1...@usenet41.supernews.com...
In fact, apart from being twice as verbose as my reply to Bill, where in
essence does your reply to my posting differ?
1) Access/VBA is supposed to clean up Object variables
2) It doesn't always do this
3) It is easier, in the long run, to do this explicitly.
Michael Kaplan wrote in message ...
>Yes, but mine has the virtue that no one trusts Microsoft to not have bugs,
>so when they understand that they would have to trust them to have no bugs,
>they suddenyl go from self-righteously refusing to close stuff to wanting
to
>do it. :-)
>
>Michael
>
>Keri Hardwick <ke...@sprintmail.com> wrote in message
>news:7arthc$8i6$1...@ash.prod.itd.earthlink.net...
>> My approach is more simplistic: "Doesn't hurt, could help. Might as
>well."
>> Keri
>>
>> Michael Kaplan wrote in message ...
>> >Everyone always has trouble with this whole idea, so I try another tack:
>> >
>> >"Microsoft has promised that VBA will always free up object variables
and
>> >all resources associated with them when they go out of scope, and that
>> >therefore you do not strictly need to do this. Thus, if you trust
>Microsoft
>> >that much, never bother to close or set to nothing and everything will
be
>> >peachy.
>> >
>> >If you believe there may be one or more bugs in a feature that Microsoft
>> has
>> >implemented, you may decide it is in your best interest to explicitly
>close
>> >what you open and always set object variables to nothing, without
>> exception,
>> >just in case one of these bugs would keep Access from being able to
close
>> or
>> >would tie up system resources while your app is running. Its up to you."
>> >
>> >Maybe people will listen to it this way? :-)
>> >
>> >Michael
>> >
Lyle Fairfield wrote:
>
> You convinced me the first time,Michael. Now, I'm getting paranoid ...
> worrying about nothings.
>
> --
> Lyle
>
> Michael Kaplan <mic...@spamless.trigeminal.com> wrote in message
> news:uLgaFdnX#GA.226@upnetnews05...
Abbot Cooper
cooper_N...@mediaone.net
(remove "_NoSpam_" from address when sending)
Rebecca Riordan wrote in message <36d2...@news.uk.ibm.net>...
In article <OVRR6fBX#GA.233@upnetnews03>,
"Bill Berry" <bill...@email.msn.com> wrote:
> I want a rule-of-thumb on whether every procedure that uses a local
> recordset (or other DAO) object variable needs to have Set <objname>=Nothing
> at the end.
>
> I understand that there are many dark corners and details to this issue, but
> I'mmainly concerned with the simple scenarios exemplified below:
>
> I'm writing a function (that may be called hundreds of times per day) that
> uses a recordset object to look up some data. I'm just returning a string
> value from the function, not any objectreferences. All variables in the
> procedure are local-to-the-procedure in scope. If one of those variables is
> a recordset, will it automatically be "set to Nothing" when it goes out of
> scope (i.e. the procedure finishes) or do I have to manually do a
> Set<variable>=Nothing ?.
>
> I want to do the right thing to keep memory "clean and tidy", but I don't
> want to have (lots of?!) Set <variable>=Nothing statements which are
> functionally redundant.
>
> Please help me with the straight scoop on this basic situation. TIA
>
> Bill Berry
>
>
-----------== Posted via Deja News, The Discussion Network ==----------