Troubleshooting Guide: SQL Server Error 8991 – Invalid Address Range
Why This Error Happens
Error 8991 occurs when SQL Server’s memory manager detects that a pointer address range passed during a memory allocation or deallocation operation does not correspond to a valid, previously allocated region. This is typically caused by database corruption affecting in-memory OLTP (Hekaton) structures, a mismatch between SQL Server’s memory-mapped file pointers and actual committed memory, or corrupted buffer pool pages. It can also surface after improper shutdowns, faulty RAM, or incompatible third-party memory-scanning tools (such as antivirus or endpoint protection software) interfering with the sqlservr.exe process address space.
Step-by-Step Resolution Guide
Step 1: Check for Hardware-Level Memory Corruption
- Run Windows Memory Diagnostic Tool by executing
mdsched.exefrom the Run dialog on Windows Server 2025 / Windows 11. - Review results in Event Viewer under Windows Logs > System after reboot, filtering for source “MemoryDiagnostics-Results”.
- If errors are found, contact your hardware vendor to replace faulty DIMMs before proceeding further.
Step 2: Run DBCC CHECKDB to Identify Corruption
- Open SQL Server Management Studio (SSMS) and connect to the affected instance.
- Execute the following command against the database reporting the error:
DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
- If corruption is found in In-Memory OLTP filegroups, note the affected table/checkpoint file group for targeted repair.
Step 3: Exclude SQL Server Processes from Antivirus/EDR Scanning
- Navigate to Windows Security > Virus & threat protection > Manage settings > Exclusions.
- Add exclusions for:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\sqlservr.exe- The data and log file directories (e.g.,
D:\SQLData\andL:\SQLLogs\) - Restart the SQL Server service via
services.mscto apply the exclusion cleanly.
Step 4: Review and Adjust Max Server Memory Configuration
- Open SSMS, right-click the server instance, and select Properties > Memory.
- Ensure “Maximum server memory” is set below total physical RAM (leave at least 4GB for the OS on servers with 32GB+ RAM).
- Run the following to verify current configuration via T-SQL:
EXEC sp_configure 'max server memory';
Step 5: Restore From a Known Good Backup if Corruption Persists
- If
DBCC CHECKDBreports unrepairable corruption tied to this error, restore the database from the last verified clean backup. - Use
RESTORE DATABASE [YourDatabaseName] FROM DISK = 'BackupPath.bak' WITH REPLACE, RECOVERY; - Validate backup integrity beforehand using
RESTORE VERIFYONLY FROM DISK = 'BackupPath.bak';
Alternative or Verification Steps
- After applying fixes, monitor the SQL Server Error Log (
ERRORLOGfile in theLogdirectory) for 24-48 hours to confirm Error 8991 does not recur during peak load. - If the issue persists despite clean
DBCC CHECKDBresults and verified hardware, enable trace flag 3042 temporarily and capture a memory dump during the next occurrence for deeper analysis via Microsoft Support diagnostics.