PC Review


Reply
Thread Tools Rate Thread

AJAX connection leak

 
 
David Cohen
Guest
Posts: n/a
 
      24th Aug 2010
I have an AJAX page where I am doing a partial page refresh every 5 seconds.
My Page_Load() function contains the following:

SqlConnection conn = new SqlConnection(...);
conn.Open();
// database access stuff
conn.Close();

Even though I am closing the connection, I find that whenever this page
stays open for a long time, I get an "all pooled connections were in use and
max pool size was reached" error message. Does anybody know why?

 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      2nd Sep 2010
Hi David,

What exactly do you do between Open and Close? If you open a datareader,
you'll need to close it, too.

I have a couple of suggestions:
1. Cache a single connection in the Application variable
2. If you use your code, make sure that the conn.Close in the finally part
of a try catch.
3. As mentioned, close datareader in finally, also or use using(
SqlDataReader reader = cmd.ExecuteReader())..

Mike
http://www.homemadepride.com

"David Cohen" <(E-Mail Removed)> a écrit dans le message de
news717176A-5D48-44B7-BC51-(E-Mail Removed)...
>I have an AJAX page where I am doing a partial page refresh every 5
>seconds. My Page_Load() function contains the following:
>
> SqlConnection conn = new SqlConnection(...);
> conn.Open();
> // database access stuff
> conn.Close();
>
> Even though I am closing the connection, I find that whenever this page
> stays open for a long time, I get an "all pooled connections were in use
> and max pool size was reached" error message. Does anybody know why?


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX ScriptManager Memory Leak =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?= Microsoft ASP .NET 11 4th Jul 2007 10:54 AM
AJAX memory leak(?) BillE Microsoft ASP .NET 8 21st Jun 2007 04:33 PM
Leftover Connections in Connection Pool (connection leak) hiriumi@gmail.com Microsoft ADO .NET 2 25th Jan 2007 04:09 AM
Connection Leak. sk.rasheedfarhan@gmail.com Microsoft ADO .NET 5 24th Dec 2006 12:01 PM
Connection Pooling LEAK? Owen Mortensen Microsoft ADO .NET 4 10th Feb 2005 01:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:59 AM.