Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
Various memory errors are logged to SQL Server error log when using SQL CLR objects
Article ID: 969962 - View products that this article applies to.
RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.
When using SQL CLR stored procedures, user defined functions, user defined data types, or user defined aggregates, you many notice one or more of the following error messages being logged in the SQL server error log when running on a 32 bit instance of either SQL Server 2005 or 2008.
Error message 1
AppDomain 2 (xxx) is marked for unload due to memory pressure.
Error message 2
AppDomain Trio.dbo[runtime].xx was unloaded by escalation policy to ensure the consistency of your application. Out of memory happened while accessing a critical resource.
Error message 3
Failed to initialize the Common Language Runtime (CLR) v2.0.50727 due to memory pressure.
Error message 4
Error: 6532, Severity: 16, State: 49. .NET Framework execution was aborted by escalation policy because of out of memory.
Additionally, you may see the above error messages with SQL Server 2008 features which use SQL CLR internally, like DMF (Declarative Management Framework) and spatial data types.
Error message 1 could just be an informational message indicating that SQL CLR is responding to the memory pressure on the system. If this is an intermittent error message and is not affecting the execution of SQL CLR objects, the message can likely be ignored.
The following steps can help resolve or alleviate the problem:
If you had followed the above guidelines but continue to receive the errors mentioned in the symptoms section and cannot immediately migrate to 64 bit severs, you can try giving more memory to SQL CLR by increasing the 'MemToLeave' or 'Non buffer pool memory' to 384 MB. This can be done by adding the -g384 switch to the startup parameters under the Advanced tab of SQL server instance properties (http://msdn.microsoft.com/en-us/library/ms345416(SQL.90).aspx
(http://msdn.microsoft.com/en-us/library/ms345416(SQL.90).aspx)) in SQL Server configuration manager.
Please be advised that you should not increase the MemToLeave value arbitrarily. Setting this value too high may have an adverse impact on buffer pool memory usage, which could lead to performance issues with the SQL server instance. Additionally, you may continue to experience SQL CLR memory errors discussed in the article even after adjusting the non-buffer pool memory, in which case further troubleshooting will be needed to identify the root cause.
For more information about the products or tools that automatically check for this condition on your instance of SQL Server and on the versions of the SQL Server product, see the following table:
Collapse this tableExpand this table
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.
(http://go.microsoft.com/fwlink/?LinkId=151500)for other considerations.
Article ID: 969962 - Last Review: April 4, 2012 - Revision: 3.0