4

I have a .NET client application running a very large batch of queries. I have SQL Server's max server memory configured, however when I run the query I get several messages like:

An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.

When I look at the server it has 20GB of memory free and SQL Server is only using 4.8GB (and that number is stable).

I've tried putting some GO statements in, but to no avail. I don't know where it is hitting the memory issues. None of the queries return more than a few rows.

How can I get around this memory issue?

I see someone posted a similar issue but I'm not sure how to allow SQL to write the results to a file rather than trying to put it all in the output window.

Responses to comments

  • The memory is set to 22528000.
  • A user is running a .NET application (which "calls" a SELECT statement) on his desktop. His desktop configuration is i7 processor with 32gb.
  • I'm not running it on SSMS.
  • The DBMS is SQL server 2012, SP3.
MDCCL
8,5303 gold badges32 silver badges63 bronze badges
asked Aug 29, 2017 at 16:02
0

1 Answer 1

4

The error you are seeing is being generated at the client end. Typically this error occurs when the client runs out of memory while trying to display or consume the result set. Try running a smaller subset of queries, and ensure the client is properly disposing objects as they are no longer required.

user112359
731 gold badge2 silver badges8 bronze badges
answered Aug 29, 2017 at 16:08
1
  • 1
    @user112359 I'm afraid your vendors are wrong unless a CLR function is being called in the query and that is running out of memory. But I'm not even sure that would generate the message you're reporting here. It's a .NET runtime error that is almost certainly not being caused by the database, unless the query is returning an absurd amount of data and you want to label that as "the database" causing it. Commented Aug 29, 2017 at 21:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.