How much should I need to Dispose() of

  • Thread starter Thread starter Raterus
  • Start date Start date
Angel
Pools are per appdomain, if your appdomain gets unloaded you will create a
new pool the next time you reload your page This is perfectly normal
behavior, IIS will automatically unload appdomains under stress.

Thanks a lot for explaining this. It does shed some light onto my
problem. Combined with my knowledge that the CLR Data counters do not
reset properly it completes the picture. The new pools/connections are
being created but the closure of the old ones is not being reflected
on the graph.
The other problem you are seeing is more than likely a connection leak in
your code. I am not sure if you read my other post in this thread but if you
are calling SqlConnection close on the finalizer for the page this is almost
certainly your problem.

I used the following code to test if I run out of pooled connections:

conn = new SqlConnection();
try
{
conn.ConnectionString = ConfigurationSettings.AppSettings[
Constants.Global.PooledDsnKeyName ]; // Conn timeout = 2 sec
conn.Open();
}
catch(Exception)
{
if (conn.State != ConnectionState.Closed) conn.Close();
conn.ConnectionString = ConfigurationSettings.AppSettings[
Constants.Global.NonPooledDsnKeyName ];
conn.Open();
}

This kicked in only once in a series of load tests and only for under
a min so I guess, I don't have leaks.... Actually, I left it in place
for production - just in case :)

Thanks again for your help!
Dmitri

Angel Saenz-Badillos said:
Dmitri,
Pools are per appdomain, if your appdomain gets unloaded you will create a
new pool the next time you reload your page This is perfectly normal
behavior, IIS will automatically unload appdomains under stress.

The other problem you are seeing is more than likely a connection leak in
your code. I am not sure if you read my other post in this thread but if you
are calling SqlConnection close on the finalizer for the page this is almost
certainly your problem.

Hope this helps,

--
Angel Saenz-Badillos [MS] Managed Providers
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.


Dmitri Khanine said:
Jon Skeet [C# MVP] <[email protected]> wrote in message
How are you determining that a new pool is being created? I don't know
the details, but it might be possible that something is noticing that
connections are leaking, and deciding to start a new pool in case
connections have been going stale.

.NET CLR Data performance counter tells me that the new pool is being
created. Nothing in documentation (unless I overlook something!)
suggests that this is something the pooler can do. The new pool can
only be created when the connection string has changed.

Also this happens even when I have a max pool size set to 100 and the
number of pooled connections is only 65!
 
Back
Top