Sql-server – Why SQL server unload CLR assembly every midnight

sql serversql-server-2008

Every midnight not a specific time, the sql server will unload the CLR assembly. The reason is that due to memory pressure, the assembly is marked with unload and will be unloaded soon.

How to make the assembly never unloaded, since reload will impact the query performance a lot.
Second question is how to find the root cause of sql server reported high memory pressure at midnight?

I was using the performance monitor to track the memory usage of each OS processes, and didn't see the huge memory usage increase at that time.

The system is Windows Server 2008 R2 and SQL server 2008 R2.

The system is x64. Sql server is x64 standard.

The log is "AppDomain 9 ( is marjed for unload due to memory presure.)"

I don't think there is a schedule job at that time.

The reason of why the memory pressure is high at that time is unknown.

Best Answer

SQL server 32 bit instance's virtual memory is limited to 4GB. If you use SQL CLR extensively with a SQL Server 32 bit instance and experience one or more of above errors, Microsoft recommends that you migrate to a 64 bit SQL Server. This will enable SQL CLR to access more virtual memory and may prevent the above errors from happening in your environment.

For futher information check out the following page: http://support.microsoft.com/kb/969962