Wednesday, July 31, 2013

Connection Pooling and connection leak

Hi,


There is no way to know. GetPreparedConnection returns an open connection and we have no idea what you'll do with it.


Do you have a full pool issue ? If you use perfmon.exe to check those performance counters : http://msdn.microsoft.com/en-us/library/ms254503.aspx while running your app, it could give an idea about when it happens (i.e on which forms or pages).


Depending on your app, some relatively light code changes could allow to better track that (for exemple using the SqlConnection.Disposed or StateChanged events) by writing to the Debug window.


Once you fixed your issue, you'll likely have to open a new thread to see if your current pattern couldn't be improved (not sure how the returned connection is used, but basically it should be kept as local as possible and even if using a "reader" you do have an option to dispose the connection when the reader is "closed". Your main app code should get "data", not a connection that it will use to get at those data).




Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".


No comments:

Post a Comment