Solved

"There are not enough free System Resources to perform this operation."

Posted on 2006-11-10
8
389 Views
Last Modified: 2008-01-09
I get this error "There are not enough free System Resources to perform this operation." while running a report engine that I'm upgrading to use ADO.NET (worked fine with ADO).  It is essentially checking a Queue table every 3 seconds to see if a request has been made.  I'm using a SQL Data Reader, SQL Connection and SQL Command.

Here's the odd thing though, when the program throws the system resources error there are still plenty of system resources left.  The hard disk has 8 of 20 gig left.  The engines at crash time are taking up 54MB and 37MB of memory respectively and the commit charge via the task manager is only 287MB/1246MB.

I'm disposing of my SQLCommands and setting the commands and data reader = nothing.  The connection is left open throughout the lifetime of the .EXE.  Thoughts on why this is happening?
0
Comment
Question by:IUFITS
8 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 17915992
This isn't an answer, but I've had this before and a reboot sorted it out.
Never found out what the problem was though :(
0
 
LVL 3

Author Comment

by:IUFITS
ID: 17916443
I'm puzzeled, the other kicker is, I have two database connections each database residing on a different server (one is our error and notification logging database).

                Dim Sqlstmt As String = "UPDATE tbl_Application_Codes SET ProgramLastRun='" & Now() & "', ProgramLastRunBy='" & My.User.Name & "', ProgramLastRunIP='" & GetIPAddress() & "' WHERE ApplicationCode='" & pAPPLICATION_CODE & "'"
                Dim myConnection As New System.Data.SqlClient.SqlConnection("server=<server>;database=Error_Log;uid=<user>;pwd=<Password>")
                myConnection.Open()

                Dim myCommand As New System.Data.SqlClient.SqlCommand(Sqlstmt, myConnection)
                Dim p As Integer = myCommand.ExecuteNonQuery()

                myCommand.Dispose()
                myCommand = Nothing
                myConnection.Close()
                myConnection = Nothing

I'm running the above code in the form load event of the main form.. it calls a sub in an custom notification object which contains the above... now, to me it looks like the connection should open, run the statement and close, but it doesn't and it doesn't throw an exception to make me think it's not getting there.  There continues to be two open connections to that database server and countless others with TIME_WAIT (I can only assume it opens then closes many over and over because the port number continues to go up when I check netstat)....   Clearly there is something I don't understand with the connection process.
0
 
LVL 3

Author Comment

by:IUFITS
ID: 17916651
I'm utterly perplexed.  Something else I noticed which is flakey, I removed SERVER1 from EVERY connection string in my source code a while back...  it's NOT there but my program continues to open up connections to it and close them (or I assume that because there's a slew of TIME_WAIT connections when my program starts).  Why does it continue to reference it... when I start my program and run netstat to monitor (I've used a packet sniffer which verifies my program is sending that server info).

How can my program be opening or talking to a server that exists nowhere in my code (though it used to) and could this somehow be related?  This makes me miss my trouble free version with classic ADO.  :P
0
 
LVL 3

Author Comment

by:IUFITS
ID: 17916857
Disregard the SERVER1 comment...  I forgot this is a report server and server1 was where the report was getting it's data from.  :P  This perplexed on the memory issue though.  Does it matter what order your dispose and set things equal to nothing in?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:magpie3d
ID: 17928752
.NET will pool database connections, and keep them open for a while in case they are needed again.  That could explain why it looks like the connections aren't being closed.

I would call Dispose on the Connection object too, just be sure that it's not leaking anything.
0
 
LVL 5

Accepted Solution

by:
prashantagarw10 earned 500 total points
ID: 17929755
I also got this prob. and i think i added something to connection string to fix this up.
I think it was something like connectiontimeout or simply timeout.

By the way why do u keep closing and opening connections everytime. Dont close a connection. Use persistant connection which u open at start of report. and close it at application end. and to address the problem in between by closing of conn. use a good try catch block and call ur sub to open a conn. in case its broken in between.

Prashant
0
 
LVL 5

Assisted Solution

by:prashantagarw10
prashantagarw10 earned 500 total points
ID: 17929789
I think i got it. It was Connection Lifetime property. In ur case i wd. suggest to set it  to 10 in case you plan to close and open connections each time. But if you use a persistant connection dont add this to connection string.

Prashant
0
 
LVL 3

Author Comment

by:IUFITS
ID: 17990746
I set a persistant connection and re-ordered the order I was releasing objects so I didnt' leave any hanging.  That helped.  My true leak though was from using NotifyIcon and not using the DestroyIcon API to free the resource since the icon setting was just a pointer.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now