Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Closing Recordsets
Quick question about closing recordsets and connection objects.  We're in
the process of rewriting a TON of bad code.  None of it is even remotely
tabbed properly, it's impossible to read half the time and it never closes
connection objects or recordsets.  Unfortunately, I've been assigned the
task of closing them.  I assume I'm just doing:

recordset.close
Set recordset = Nothing

conn.close
Set conn = Nothing

...whenever it's no longer needed.  I guess that my question is, how do I
need to handle redirects within a page.  Should I close/set to nothing
before a redirect, or by the page losing "focus", will these objects be
released anyway?

Are there any general rules of thumb that might save me some time going
through the 1,000,000+ lines of code?

Thanks!



Report this thread to moderator Post Follow-up to this message
Old Post
James
10-29-04 08:55 PM


Re: Closing Recordsets
James wrote:
> Quick question about closing recordsets and connection objects.
> We're in the process of rewriting a TON of bad code.  None of it is
> even remotely tabbed properly, it's impossible to read half the time
> and it never closes connection objects or recordsets.  Unfortunately,
> I've been assigned the task of closing them.  I assume I'm just doing:
>
> recordset.close
> Set recordset = Nothing
>
> conn.close
> Set conn = Nothing
>
> ...whenever it's no longer needed.  I guess that my question is, how
> do I need to handle redirects within a page.  Should I close/set to
> nothing before a redirect,

Yes. Any code that appears after a redirect will not be executed.

> or by the page losing "focus", will these
> objects be released anyway?

Maybe. It's the times that they don't close automatically that cause the
memory leaks

>
> Are there any general rules of thumb that might save me some time
> going through the 1,000,000+ lines of code?
>
Close and destroy child objects (recordsets, command objects) before closing
and destroying parent objects (connections). Note: command objects can't be
closed, only destroyed.

Or, the "Things I learned in kindergarten" version:
if you open it, close it
if you create it, destroy it

Sorry, there's nothing i've said here that will save you any time.

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.



Report this thread to moderator Post Follow-up to this message
Old Post
Bob Barrows [MVP]
10-29-04 08:55 PM


Re: Closing Recordsets
> Sorry, there's nothing i've said here that will save you any time.

Not necessarily true.  Going through the code now and cleaning it up, while
boring and monotonous, will save time and gray hair later when trying to
find the source of a memory leak...

A



Report this thread to moderator Post Follow-up to this message
Old Post
Aaron [SQL Server MVP]
10-29-04 08:55 PM


Re: Closing Recordsets
Fair enough.  We've had an issue where maybe once few days, the site is
horribly slow and basically needs to be rebooted.  I have the distinct
feeling that this might solve that problem, as we've been unable to track it
down anywhere else.

"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:Onad34cvEHA.1204@TK2MSFTNGP10.phx.gbl... 
>
> Not necessarily true.  Going through the code now and cleaning it up,
while
> boring and monotonous, will save time and gray hair later when trying to
> find the source of a memory leak...
>
> A
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
James
10-29-04 08:55 PM


Re: Closing Recordsets
Aaron [SQL Server MVP] wrote: 
>
> Not necessarily true.  Going through the code now and cleaning it up,
> while boring and monotonous, will save time and gray hair later when
> trying to find the source of a memory leak...
>
> A
:-)
I meant clean-up time. Nothing I said provided any shortcuts to make this
task easier.

Bob
--
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.



Report this thread to moderator Post Follow-up to this message
Old Post
Bob Barrows [MVP]
10-29-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

ASP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:20 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.