Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


System.OutofMemoryException Error


System.OutofMemoryException Error

Author
Message
Venky Subramaniam
Venky Subramaniam
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 135
Hi,
I am trying to run a 'SELECT' query that joins three tables, one of which has 41 million rows and the other two in, say hundred-thousands. My query uses the primary keys defined on all the tables but also builds a concatenated string based on a CASE statement! After 16 million rows I keep getting the above error. The server is quite powerful with 32 GB RAM running Windows Server 2008 and SQL Server 2008 64-bit! Can anyone suggest how to overcome this anomaly? There was one more user that was accessing the server but I do not think it really matters for such a powerful hardware! I even tried to use a query hint to make the optimizer choose the correct index but...

Any help is appreciated.
Thanks
Venky
mrdenny
mrdenny
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 222
System.OutofMemoryException is a .NET error message. Are you using a CLR procedure or function in your query? How are you running the query?
Venky Subramaniam
Venky Subramaniam
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 135
Hello Mr. Denny,

Thanks for your response. To answer your question, no, I am not using any CLR, function or a T-SQL stored procedure. I just ran the query (as a batch) on query window and this is the exact error I get:
An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.

Does this help?
Thanks again for your response.
Regards,
Venky
jeff.mason
jeff.mason
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1153 Visits: 2126
Sounds like a client issue -- like your client doesn't have enough memory to handle the result set that is returned from the server.
mrdenny
mrdenny
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 222
That's a problem with SQL Server Management Studio running out of memory. How much RAM is on the machine you are running management studio on? How much data is coming back from the query you are running?
Venky Subramaniam
Venky Subramaniam
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 135
Considering Jeff's suggestion, I ran the query on the server itself but with the same results. As Denny points out it is the problem with SSMS (which is built on .NET technology :-(, and as corrrectly pointed out, the error message might be reflecting that).

I even tried to run the same query through sqlcmd, but the results came up with nothing but the header...I am flummoxed! BTW, the query is supposed to return about 42 million rows with just three columns..

The server has 32 GB RAM, 8 CPUs, and SQL Server has been configured to utilize as much as possible, yet...I even searched other sites where one of which had some kind of pointers by a Microsoft expert. He suggested to test it with TOP n rows (I tried 10000 and it works perfectly fine and very fast...) It stops around 33 mil! Sigh!

Should you have any other ideas that I can explore (like would running the query as an SP make difference. Ths SP can probably write the results in a table), please feel free to suggest.

Thanks again for your support.
Venky
jeff.mason
jeff.mason
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1153 Visits: 2126
By "client" I did mean client app, so I was saying the same thing about SSMS. Why do you need 16 million plus rows to appear on your client? Wouldn't outputting to a file be sufficient? Client apps aren't designed to hold that much data.
Derrick Smith
Derrick Smith
Mr or Mrs. 500
Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)

Group: General Forum Members
Points: 594 Visits: 715
Venky Subramaniam (8/26/2010)
The server has 32 GB RAM, 8 CPUs, and SQL Server has been configured to utilize as much as possible


That's most likely your issue. There is not enough room outside of the cache to store all the rows. You need to leave some space for the OS to breathe. Also keep in mind having a logged in session + SSMS open requires a few hundred megs before you even run a query.
Venky Subramaniam
Venky Subramaniam
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 135
Thank you all guys for your prompt responses. Yes, despite the initial failure of the process, I could at least gauge how much can SSMS hold in terms of data for display. before it bursts at the seams :-)

BTW, I got my work done through a simple transfer to a table.

Thanks again,
Venky
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search