Re: Revisiting an old friend: Set oRS = Nothing

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 05/05/04


Date: Wed, 5 May 2004 15:08:10 -0400

Dave Anderson wrote:
> Last September, some of us engaged in a discussion of freeing
> resources in ASP scripts written in JScript. It can be seen here:
> http://tinyurl.com/2flzt
>
> I recently read Eric Lippert's article on the use of *Nothing*
> assignments in VB
> (http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx)
> right before going out of scope, and was shocked by what he had to
> say, and I must say it has me curious about the implications for ASP,
> whether written in JScript or VBScript.
>
> Like Lippert, I have seen a lot of documentation/advice that suggests
> a need for such assignments, but little empirical evidence that it
> matters. I do not mean to suggest that *Nothing* assignments are
> NEVER required, I simply wonder if anyone has bothered to check if it
> still matters with recent generations of IIS and such common tools as
> ADO or CDO.
>
> Comments?

I don't understand your point. The consensus of most of the people on that
page is that ADO objects should be explicitly destroyed, especially in ASP.
The comments about bugs caused by failure to explicitly destroy ADO and DAO
objects should not be taken lightly.

In the many years that I have been coding, the documentation for every
version of VB/VBA that I have used has ALWAYS said: objects are destroyed
when they go out of scope. Nevertheless, we came across memory leaks, bugs,
etc, which were resolved by explicitly destroying the objects in question.
This has always suggested to me that the documentation has always been
wrong: there are circumstances where the auto-cleanup failed, which lead to
many authors adding the "if you open it, close it; if you create it, destroy
it" mantra to their "best practices" lists. It was not makework. There are
many documented failures caused by non-adherence to this principle. Several
of those failures are mentioned in your cited blog.

For me, it's easier to remember to destroy all objects, than to remember to
destroy just my ADO objects.

Bob Barrows

-- 
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Relevant Pages

  • Re: Aggregation vs composition
    ... Not only does X destroy the ... the container must document when this ... on the clients sticking to the rules laid down by the documentation. ... I agree that the cooperation lies in the documentation, ...
    (comp.object)
  • Re: Aggregation vs composition
    ... >> This is the diagram that we are discussing about. ... Not only does X destroy ... >> int, it has no other choice but doing so as it cannot prevent the ... >> on the clients sticking to the rules laid down by the documentation. ...
    (comp.object)
  • Semantics of InactiveDestroy
    ... I have a problem with parsing the documentation regarding the "InactiveDestroy" attribute on DB handles. ... The "InactiveDestroy" attribute can be used to disable the *database ... only the implicit call from DESTROY ... the trace log whenever a DBI or handle tracemethod is called. ...
    (perl.dbi.users)
  • Re: cvs commit: src/usr.bin/login login.c
    ... > you log in using pam_krb5, you will have tickets. ... > documentation, you have to destroy them yourself with `kdestroy'. ...
    (FreeBSD-Security)