System.OutOfMemoryException mystery solved

  • This isn't actually a question, just thought I would share what I have learned in case anyone else runs into the same issue.

    Occasionally, SSMS will return a "System.OutOfMemoryException" rather than the result set you were hoping for. Microsoft's documentation explains that this is caused by the SQL Client being a 32-bit process and a result set being larger than 2 GB, thus exceeding the address space of the application. But, what if your query was something like: Select top 1 idintegercolumn from sometable? Surely one integer value can't be greater than 2 GB?!

    After having the above query fill the memory space of SSMS a few times, it dawned on me that the issue was not the result set, but was most likely intelisense, where behind the scenes SSMS was attempting to gather metadata on quite a few objects in the particular database I was working in (over 100k tables and 12k views, for starters).

    I tested the same query, but this time using the master database and it worked fine, which backs up my hypothesis. Of course, I'm still open to another explanation, so if anyone has other ideas, I'd love to hear them.

    Kind regards,

    Ernest Libertucci

  • I've had the same error generating a massive execution plan - so intellisense would tie in.

    The client is still 32 bit?

    Doug

  • Yes, see knowledge base article here:

    http://support.microsoft.com/kb/2874903

  • I get this error after my ssms has been open for a long time, and i have a few connections open. Generally I get it when trying to view job history for all jobs or something similar. I find if I close down SSMS and reopen it the problem goes away.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply