SQL CLR memory error - Failed to initialize the Common Language Runtime (CLR)

  • Hello,

    SQL Server details: Microsoft SQL Server Enterprise Edition (64-bit) / 10.50.4000

    Hardware: 2-node cluster, 132GB RAM of which 120GB allocated to SQL instance, 32 core

    OS: Windows Server 2008 R2

    Issue:

    A number of CLR functions (RegEx, see below for example) that have been use for the past 3 to 4 years now give the below error.

    Msg 6513, Level 16, State 27, Line 2

    Failed to initialize the Common Language Runtime (CLR) v2.0.50727 due to memory pressure. This is probably due to memory pressure in the MemToLeave region of memory. For more information, see the CLR integration documentation in SQL Server Books Online.

    Here's the code for one of the CLRs that produce the message above (same CLR runs fine on development instance).

    ALTER FUNCTION [dbo].[RegExReplace](@InputString [nvarchar](255), @Pattern [nvarchar](100), @ReplaceString [nvarchar](255))

    RETURNS [nvarchar](255) WITH EXECUTE AS CALLER

    AS

    EXTERNAL NAME [SQLRegEx].[SqlRegex].[RegexReplace]

    No changes have been made to the CLRs or to the SQL installation or on the database or the hardware.

    Any idea what could be causing this?

  • There are a few possibilities in KB969962 - Various memory errors are logged to SQL Server error log when using SQL CLR objects.

    I know it says it's about 32-bit, but it does say buried in there that upgrading to 64-bit "may prevent the errors"...

    Thomas Rushton
    blog: https://thelonedba.wordpress.com

  • Thanks for that. I had seen that earlier but not sure if it applies. We're running 64-bit SQL Server on 64-bit OS. The hotfix itself has not been installed on the server...

  • The most probable cause of this error is SQL CLR encountering memory pressure

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

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