Solved

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

Posted on 2006-11-10
8
419 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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