Dispose won't help if the connection is orphaned or still in use.
Connection pool timeouts are caused by one thing: the connection pool is
full. Why does the pool fill when it gets to 100 connections when 5 should
be enough for a healthy system? Generally, there's two reasons:
1) The connection was not done in time to be reused by the next request.
To compute this, divide the available bandwidth of the system (its
processing power) by the demand. Suppose your ASP page takes 5 seconds to
service a query. This means it can handle about 12 hits/minute per
connection. If you have 120 hits/minute you're going to exhaust the capacity
of the system and your pool will overflow. The solution to this problem is
either improve the hardware performance or decrease the length of time each
ASP takes to do its job.
2) The connections are not closed when they should be. We see this very
frequently when the DataReader is used. There are many consultants and dev
organizations that prohibit the use of the DataReader for just this reason
(and others). The problem with the DataReader and the other Command methods
is that you are responsible for connection management. You have to open AND
close the connection. The language won't do it for you (in time) and ADO
won't do it unless you program it to. Unlike VB6, the GC won't close the
connections in time to use them again--especially in heavily loaded systems.
If you make a practice of creating a DR in one scope and passing it to
another, you MUST use CommandBehavior.CloseConnection AND the receiving
function MUST close the DataReader. None of the other Command methods that
require open connections have this switch so you're on your own.
To see if your connection pool is leaking, watch it with PerfMon. If it's
leveled off, that's good. It's probably not leaking. However, if you see a
stair-step pattern, you're leaking if the graph does not level off. Consider
that heavily used sites stabilize at 6-12 connections--not 80-100.
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
I'm starting to run into timeout issues on my web application with my
connection object trying to get a connection from the connection pool. I
use this connection object on every page. I make sure I Close() it after I
use it, but now I think I need to call it's Dispose() method as well, after
my page finishes. My question is, how "anal" should I be about cleaning up
before .NET's Garbage collection supposedly cleans up. Should every object
I use that has a dispose method, namely ado.net's object be disposed of?
Should I just worry about the connected layer of ado.net, connections,
commands... or should I get into disposing datasets and datatables, etc?
Thanks,
--Michael