AJAX connection leak

Discussion in 'ASP .Net' started by David Cohen, Aug 24, 2010.

  1. David Cohen

    David Cohen Guest

    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?
     
    David Cohen, Aug 24, 2010
    #1
    1. Advertising

  2. David Cohen

    Mike Guest

    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" <> a écrit dans le message de
    news:D...
    >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?
     
    Mike, Sep 2, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. minnie
    Replies:
    1
    Views:
    761
    Andrew Thompson
    Dec 13, 2006
  2. Richard Heathfield

    Leak or no leak ??

    Richard Heathfield, Jul 10, 2006, in forum: C Programming
    Replies:
    4
    Views:
    376
    Richard Heathfield
    Jul 10, 2006
  3. BillE

    AJAX memory leak(?)

    BillE, Jun 20, 2007, in forum: ASP .Net
    Replies:
    8
    Views:
    622
    BillE
    Jun 21, 2007
  4. =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?=

    AJAX ScriptManager Memory Leak

    =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?=, Jul 3, 2007, in forum: ASP .Net
    Replies:
    11
    Views:
    7,353
    =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?=
    Jul 4, 2007
  5. Replies:
    3
    Views:
    175
    Randy Webb
    Sep 14, 2006
Loading...

Share This Page