How to fix Error 6289 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 6289 – CLR Memory Allocation Failure

Why This Error Happens

Error 6289 occurs when SQL Server’s Common Language Runtime (CLR) integration fails to allocate the memory it needs from the memory manager, typically because the server is under memory pressure or the max server memory setting is configured too restrictively. This can also happen if the CLR’s internal memory allocator becomes fragmented due to long-running processes, or if the SQL Server service account lacks sufficient “Lock Pages in Memory” privileges on Windows Server 2025. In some cases, corrupted CLR assemblies or an outdated .NET integration layer following an OS or SQL Server patch can also trigger this failure.

Step-by-Step Resolution Guide

Step 1: Verify and Adjust SQL Server Memory Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run EXEC sp_configure 'show advanced options', 1; RECONFIGURE; followed by EXEC sp_configure 'max server memory'; to check current limits.
  • Ensure max server memory is not set too close to total physical RAM — leave at least 20-25% headroom for the OS and CLR on Windows Server 2025.
  • Adjust using EXEC sp_configure 'max server memory', <value_in_MB>; RECONFIGURE;

Step 2: Check and Enable “Lock Pages in Memory” Privilege

  • Open secpol.msc (Local Security Policy) on Windows Server 2025.
  • Navigate to Local Policies > User Rights Assignment > Lock pages in memory.
  • Add the SQL Server service account (e.g., NT Service\MSSQLSERVER) to this policy.
  • Restart the SQL Server service via services.msc or run net stop MSSQLSERVER && net start MSSQLSERVER.

Step 3: Rebuild or Re-register CLR Assemblies

  • Open a query window in SSMS and run ALTER DATABASE <YourDB> SET TRUSTWORTHY ON; if CLR assemblies rely on trust settings.
  • Drop and re-add any custom CLR assemblies using DROP ASSEMBLY <AssemblyName>; followed by CREATE ASSEMBLY <AssemblyName> FROM '<path>' WITH PERMISSION_SET = SAFE;
  • Confirm clr enabled is active by running EXEC sp_configure 'clr enabled', 1; RECONFIGURE;

Step 4: Apply Latest SQL Server 2025 Cumulative Update

  • Check the installed build using SELECT @@VERSION;
  • Download the latest Cumulative Update (CU) from the Microsoft Update Catalog matching SQL Server 2025.
  • Install the update and restart the SQL Server service to ensure CLR runtime libraries are patched and aligned with Windows Server 2025/Windows 11 .NET runtime versions.

Step 5: Monitor System-Level Memory Pressure

  • Open Performance Monitor (perfmon.exe) and add the counter SQLServer:Memory Manager > Total Server Memory (KB).
  • Cross-check against Memory > Available MBytes on the Windows OS level to rule out external memory contention from other applications.
  • Close unnecessary background services competing for RAM on the host.

Alternative or Verification Steps

  • To verify the fix, run a test CLR-based stored procedure or function and confirm it executes without triggering Error 6289 in the SQL Server Error Log (EXEC sp_readerrorlog;).
  • If the error persists, consider migrating the workload to a server with higher physical RAM or isolating the SQL instance on a dedicated VM to eliminate OS-level memory competition.