Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

System.OutofMemoryException Error Expand / Collapse
Author
Message
Posted Wednesday, August 25, 2010 10:56 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:16 AM
Points: 25, Visits: 112
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
Post #975350
Posted Wednesday, August 25, 2010 11:21 PM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, October 17, 2014 9:18 AM
Points: 77, Visits: 217
System.OutofMemoryException is a .NET error message. Are you using a CLR procedure or function in your query? How are you running the query?
Post #975358
Posted Thursday, August 26, 2010 12:18 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:16 AM
Points: 25, Visits: 112
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
Post #975857
Posted Thursday, August 26, 2010 12:34 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 12:51 PM
Points: 985, Visits: 1,841
Sounds like a client issue -- like your client doesn't have enough memory to handle the result set that is returned from the server.
Post #975867
Posted Thursday, August 26, 2010 12:53 PM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, October 17, 2014 9:18 AM
Points: 77, Visits: 217
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?
Post #975878
Posted Thursday, August 26, 2010 1:15 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:16 AM
Points: 25, Visits: 112
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
Post #975893
Posted Thursday, August 26, 2010 1:18 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 12:51 PM
Points: 985, Visits: 1,841
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.
Post #975898
Posted Thursday, August 26, 2010 1:28 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, April 30, 2014 12:57 PM
Points: 575, Visits: 692
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.
Post #975909
Posted Thursday, August 26, 2010 3:19 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:16 AM
Points: 25, Visits: 112
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
Post #975967
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse