|
 |
asp_web_howto thread: Why object set to nothing
Message #1 by Roger Balliger <Roger@i...> on Thu, 15 Feb 2001 19:45:01 -0800
|
|
I'm curious about the reasoning behind setting dbase connection and
recordset objects to nothing at the bottom of an ASP page that uses them.
For example, I have created a website that connects to a database for record
retrieval purposes only. No updating or editing of the records is done over
the web. Currently, I use the connection and multiple recordset objects
(database is MS Access) to connect and use the database. I do not however
set the objects to 'nothing' at anytime and it seems to work okay (although
I haven't tried it in a multiple user setting yet). I'm perplexed as to
whether or not it is really necessary to set objects to nothing. Can
someone please enlighten me as to when I should and shouldn't (if ever) set
objects to nothing.
Thanks.
Roger
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 16 Feb 2001 18:12:20 +1100
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0C09_01C09844.00F7ECE0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
I think you'll want to read this:
http://msdn.microsoft.com/library/default.asp?URL=3D/library/techart/pool
ing2.htm
and
http://support.microsoft.com/support/kb/articles/Q191/5/72.ASP
on connection pooling.
<quote> from the first article
If You Explicitly Open It, Explicitly Close It
Pooling problems are frequently caused by an application that does not
clean up its connections. Connections are placed in the pool at the time
that the connection is closed and not before. To avoid this, always
explicitly close an object you open. If you don't explicitly close it,
chances are it won't ever be released to the pool.
Even if the language you use has effective and reliable garbage
collection, an instance of an open ADO Connection or Recordset object
going out of scope does not equate to the Close method of that object
being implicitly invoked. You must close it explicitly.
Failing to close an open Connection or Recordset object is probably the
single most frequent cause of connection creep and the single largest
cause of incorrect diagnoses of pooling failure.
</quote>
Also, using
Set =3D Nothing
is good programming practice, otherwise you are relying an IIS to
cleanup after you, which is not a good thing - do it yourself. If you
.Open something you always .Close it. If you SET something, you SET =3D
Nothing
----- Original Message -----
From: "Roger Balliger" <Roger@i...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Friday, February 16, 2001 2:45 PM
Subject: [asp_web_howto] Why object set to nothing
> I'm curious about the reasoning behind setting dbase connection and
> recordset objects to nothing at the bottom of an ASP page that uses
them.
> For example, I have created a website that connects to a database for
record
> retrieval purposes only. No updating or editing of the records is
done over
> the web. Currently, I use the connection and multiple recordset
objects
> (database is MS Access) to connect and use the database. I do not
however
> set the objects to 'nothing' at anytime and it seems to work okay
(although
> I haven't tried it in a multiple user setting yet). I'm perplexed as
to
> whether or not it is really necessary to set objects to nothing. Can
> someone please enlighten me as to when I should and shouldn't (if
ever) set
> objects to nothing.
>
> Thanks.
> Roger
Message #3 by Shaun Steckley <SSTECKLEY@P...> on Fri, 16 Feb 2001 11:18:54 -0500
|
|
Setting an object to nothing releases the instance of the object. If you
don't release the instance, the server could bog with unneeded objects...
-----Original Message-----
From: Roger Balliger [mailto:Roger@i...]
Sent: Thursday, February 15, 2001 10:45 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Why object set to nothing
I'm curious about the reasoning behind setting dbase connection and
recordset objects to nothing at the bottom of an ASP page that uses them.
For example, I have created a website that connects to a database for record
retrieval purposes only. No updating or editing of the records is done over
the web. Currently, I use the connection and multiple recordset objects
(database is MS Access) to connect and use the database. I do not however
set the objects to 'nothing' at anytime and it seems to work okay (although
I haven't tried it in a multiple user setting yet). I'm perplexed as to
whether or not it is really necessary to set objects to nothing. Can
someone please enlighten me as to when I should and shouldn't (if ever) set
objects to nothing.
Thanks.
Roger
Message #4 by "Morgan, Rob" <Rob.Morgan@o...> on Fri, 16 Feb 2001 11:37:23 -0500
|
|
Is there some way outside the application to clean up objects left open?
-----Original Message-----
From: Shaun Steckley [mailto:SSTECKLEY@P...]
Sent: Friday, February 16, 2001 11:19 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Why object set to nothing
Setting an object to nothing releases the instance of the object. If you
don't release the instance, the server could bog with unneeded objects...
-----Original Message-----
From: Roger Balliger [mailto:Roger@i...]
Sent: Thursday, February 15, 2001 10:45 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Why object set to nothing
I'm curious about the reasoning behind setting dbase connection and
recordset objects to nothing at the bottom of an ASP page that uses them.
For example, I have created a website that connects to a database for record
retrieval purposes only. No updating or editing of the records is done over
the web. Currently, I use the connection and multiple recordset objects
(database is MS Access) to connect and use the database. I do not however
set the objects to 'nothing' at anytime and it seems to work okay (although
I haven't tried it in a multiple user setting yet). I'm perplexed as to
whether or not it is really necessary to set objects to nothing. Can
someone please enlighten me as to when I should and shouldn't (if ever) set
objects to nothing.
Thanks.
Roger
Message #5 by Shaun Steckley <SSTECKLEY@P...> on Fri, 16 Feb 2001 11:46:14 -0500
|
|
Reboot... Really, Microsoft says that they take care of any unneeded
objects, however I would not take that for granted when I can simply release
the instance myself...
-----Original Message-----
From: Morgan, Rob [mailto:Rob.Morgan@o...]
Sent: Friday, February 16, 2001 11:37 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Why object set to nothing
Is there some way outside the application to clean up objects left open?
-----Original Message-----
From: Shaun Steckley [mailto:SSTECKLEY@P...]
Sent: Friday, February 16, 2001 11:19 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Why object set to nothing
Setting an object to nothing releases the instance of the object. If you
don't release the instance, the server could bog with unneeded objects...
-----Original Message-----
From: Roger Balliger [mailto:Roger@i...]
Sent: Thursday, February 15, 2001 10:45 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Why object set to nothing
I'm curious about the reasoning behind setting dbase connection and
recordset objects to nothing at the bottom of an ASP page that uses them.
For example, I have created a website that connects to a database for record
retrieval purposes only. No updating or editing of the records is done over
the web. Currently, I use the connection and multiple recordset objects
(database is MS Access) to connect and use the database. I do not however
set the objects to 'nothing' at anytime and it seems to work okay (although
I haven't tried it in a multiple user setting yet). I'm perplexed as to
whether or not it is really necessary to set objects to nothing. Can
someone please enlighten me as to when I should and shouldn't (if ever) set
objects to nothing.
Thanks.
Roger
Message #6 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Fri, 16 Feb 2001 16:51:23 -0000
|
|
hit that old on/off switch!
-----Original Message-----
From: Morgan, Rob [mailto:Rob.Morgan@o...]
Sent: Friday, February 16, 2001 4:37 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Why object set to nothing
Is there some way outside the application to clean up objects left open?
-----Original Message-----
From: Shaun Steckley [mailto:SSTECKLEY@P...]
Sent: Friday, February 16, 2001 11:19 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Why object set to nothing
Setting an object to nothing releases the instance of the object. If you
don't release the instance, the server could bog with unneeded objects...
-----Original Message-----
From: Roger Balliger [mailto:Roger@i...]
Sent: Thursday, February 15, 2001 10:45 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Why object set to nothing
I'm curious about the reasoning behind setting dbase connection and
recordset objects to nothing at the bottom of an ASP page that uses them.
For example, I have created a website that connects to a database for record
retrieval purposes only. No updating or editing of the records is done over
the web. Currently, I use the connection and multiple recordset objects
(database is MS Access) to connect and use the database. I do not however
set the objects to 'nothing' at anytime and it seems to work okay (although
I haven't tried it in a multiple user setting yet). I'm perplexed as to
whether or not it is really necessary to set objects to nothing. Can
someone please enlighten me as to when I should and shouldn't (if ever) set
objects to nothing.
Thanks.
Roger
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
Message #7 by "Ken Schaefer" <ken@a...> on Mon, 19 Feb 2001 17:15:54 +1100
|
|
----- Original Message -----
From: "Morgan, Rob" <Rob.Morgan@o...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Saturday, February 17, 2001 3:37 AM
Subject: [asp_web_howto] RE: Why object set to nothing
> Is there some way outside the application to clean up objects left open?
>
Why don't you just clean up your objects yourself?
Just write a little function like:
Sub subADOClose( _
byRef objToClose _
)
On Error Resume Next
If objToClose.State = adStateOpen then
objToClose.close
End if
If isObject(objToClose) then
Set objToClose = nothing
End if
End Sub ' subADOClose
...
Call subADOClose(objRS)
Call subADOClose(objCommand)
Call subADOClose(objConn)
Cheers
Ken
|
|
 |