473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Max pool size reached exception when trying to open a new connection

hi all,

i am working on a asp.net web app and using ado.net 's SqlClient Data
Provider to connect to
sqlserver 2005. I am getting the exception "Timeout expired. The
timeout period elapsed
prior to obtaining a connection from the pool. This may have occurred
because all pooled
connections were in use and max pool size was reached." . Internally i
am using a
sqldatareader to fetch data from database. The dispose of both the
reader and connection has
been called wherever they are being used. The pool size is set to
default i.e. 100. I have
tried to analyze the issue by using the sp_who2 stored procedure in
database and checking
the count of connections to the database.What is happpening is that
sometimes the pool size
limit is being maintained and increases 100. But on the other hand, it
sometimes shoot much
above the limit of 100 and then it throws the above mentioned
exception. Why does the
connection pooler sometimes enforces the pool size limit and sometimes
fails to do that
intrigues me.

But if i use GC.Collect in my code, then in that case the connection
pool limit is adhered
to and i dont get the above mentioned exception. Can someone please
help me with it and
explain why is it happening in the first place and is there a way
around it. I don't want to
use GC.Collect() in my code.

Thanks in advance
Ramneek

Feb 12 '07 #1
1 3414
you are leaking connections. you are not always closing the connections.
you will to search your code for the bugs. having the GC will do it for
you is a bad practice. here are some rules to prevent leaking connections.

1) always use a try and finally to open/close a connection (or using).
2) never return a datareader, the opener should always close it.
3) never declaratively use a reader (from the aspx)

using a proper entity design would help prevent this.

-- bruce (sqlwork.com)

ra******@gmail.com wrote:
hi all,

i am working on a asp.net web app and using ado.net 's SqlClient Data
Provider to connect to
sqlserver 2005. I am getting the exception "Timeout expired. The
timeout period elapsed
prior to obtaining a connection from the pool. This may have occurred
because all pooled
connections were in use and max pool size was reached." . Internally i
am using a
sqldatareader to fetch data from database. The dispose of both the
reader and connection has
been called wherever they are being used. The pool size is set to
default i.e. 100. I have
tried to analyze the issue by using the sp_who2 stored procedure in
database and checking
the count of connections to the database.What is happpening is that
sometimes the pool size
limit is being maintained and increases 100. But on the other hand, it
sometimes shoot much
above the limit of 100 and then it throws the above mentioned
exception. Why does the
connection pooler sometimes enforces the pool size limit and sometimes
fails to do that
intrigues me.

But if i use GC.Collect in my code, then in that case the connection
pool limit is adhered
to and i dont get the above mentioned exception. Can someone please
help me with it and
explain why is it happening in the first place and is there a way
around it. I don't want to
use GC.Collect() in my code.

Thanks in advance
Ramneek
Feb 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Martin | last post by:
Dear Group Sorry for posting this here. I'm desperate for a solution to this problem and thought some of you might have come across it with .NET and SQL Server. Let's assume I've the following...
1
by: Ken | last post by:
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. This...
8
by: ra294 | last post by:
I have an ASP.net application using SQL Server 2000 that every once in a while I am getting this error: "System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to...
4
by: Bei | last post by:
I would like to allow more connection to SQL servers from the web application. Do you know what is the code to set maximum pool size in web.config file? Thanks
7
by: greg | last post by:
Hi We have w2k, iis5, .NET/c# I periodically receive this message and the system freezes ++++++++++++++++++++++++++++++++++++++++++++++++++ Timeout expired. The timeout period elapsed...
4
by: Guoqi Zheng | last post by:
Dear sir, I keep getting the following errors on one of my sites after clicking for many times. Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This...
5
by: DaM | last post by:
Hi guys, I'm having this problem with my ASP.Net application: I was testing the whole site, and it seem to work fine. Fast and stable, but suddenly it stopped working and this error occurred:...
1
by: Jake K | last post by:
I have a system timer that elapses every 10 seconds and must execute every ten seconds. Basically every 10 seconds I need to insert into a table. The following code, however, causes a "Timeout...
1
by: jobs | last post by:
Re: Troubleshooting Timeout expired. All pooled connections were in use and max pool size was reached. New webservers. win2003. IIS6. asp.net 2.0/ sql server 2005 and Oracle 9i through a 64 bit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.