SQL Server MemToLeave

by Andrei Hetel 9. February 2012 13:11

 

The last SQL Server problem that I was facing was too interesting - so I decide to put it here quickly.

I'm using SQLCLR (SQL Common Language Runtime) for a very long time and never had any major issue with it until yesterday. Error message, as follows:

 

.NET Framework execution was aborted by escalation policy because of out of memory.

 

SQL Server error log gives no more information. So, I start searching for a solution. I thought that I'll be lucky because in the first 10 minutes I found and download a patch from Microsoft that was solving exactly the issue that I described above. But... no, it was a patch for SQL Server 2005 SP1 and SP2 was already installed on the server (forgot to mention that the serves is not a beast but still a decent machine). As a conclusion didn't let me install it, saying that issue was addressed in SP2 (obviously not - or more exactly not in my case).

 

 

Another unhappy programmer was lucky to solve a problem using this statement:

 

DBCC FREESYSTEMCACHE ('ALL')

 

 

As you can imagine, it didn't work. I read a lot of stuff about configuring SQL server memory, MemToLeave usage ect and I won't enter in detail explaining how it works. Last resort was to modify a SQL Server startup parameter (famous -g).

 

For this you need to open SQL Server Configuration Manager and select your instance, see picture.

 

SQL Server Configuration Manager

 

Right click, Properties, Advanced. Modify "Startup Parameters" by adding -g500 (for example - default value is 256).

 

SQL Server Service Properties

 

Happy coding!