I've seen multiple threads (several in the last 6 months or so) on this
topic, but I wanted to clarify my practices. I understand the need for
cleaning object variables by setting them to Nothing and/or closing
them, but I'm not sure about the order.
As I understand it all object variables that I create like:
Set rs = SomeExistingRec ordset
need to be cleaned up via:
rs.Close
Set rs = nothing
Those I didn't create like:
Set db = CurrentDB
or
Set db = DBEngine(0)(0)
need to be cleaned only via:
Set db = Nothing
1) Is the order of the Close method and the Set statement important?
2) Are these practices adequately freeing the memory used by the object
variables?
3) Is the Close unnecessary for object variables like Recordsets,
Connections, and other pointers of the sort?
4) How should pointers to Containers be handled?
Thanks in advance for revisiting a very old topic.
topic, but I wanted to clarify my practices. I understand the need for
cleaning object variables by setting them to Nothing and/or closing
them, but I'm not sure about the order.
As I understand it all object variables that I create like:
Set rs = SomeExistingRec ordset
need to be cleaned up via:
rs.Close
Set rs = nothing
Those I didn't create like:
Set db = CurrentDB
or
Set db = DBEngine(0)(0)
need to be cleaned only via:
Set db = Nothing
1) Is the order of the Close method and the Set statement important?
2) Are these practices adequately freeing the memory used by the object
variables?
3) Is the Close unnecessary for object variables like Recordsets,
Connections, and other pointers of the sort?
4) How should pointers to Containers be handled?
Thanks in advance for revisiting a very old topic.
Comment