The symptom
Queries, logins or background tasks fail with:
Msg 701, Level 17, State 123
There is insufficient system memory in resource pool 'default' to run this query.
The pool name may be default, internal or a Resource Governor pool you created. The error log often shows a DBCC MEMORYSTATUS-style dump just before or after. The instance is usually still up, but new work fails in bursts.
Error 701 is different from RESOURCE_SEMAPHORE waits. With 701 the memory is gone and SQL Server cannot allocate more. With RESOURCE_SEMAPHORE queries are waiting in line for a memory grant. If you see waits and no 701 errors, use the memory grant runbook instead.
Quick checks (first 5 minutes)
1. Is it the whole process or one pool?
SELECT physical_memory_in_use_kb / 1024 AS sql_physical_mb,
locked_page_allocations_kb / 1024 AS locked_pages_mb,
memory_utilization_percentage,
process_physical_memory_low,
process_virtual_memory_low
FROM sys.dm_os_process_memory;
SELECT total_physical_memory_kb / 1024 AS os_total_mb,
available_physical_memory_kb / 1024 AS os_available_mb,
system_memory_state_desc
FROM sys.dm_os_sys_memory;
SELECT name, value_in_use
FROM sys.configurations
WHERE name IN ('max server memory (MB)', 'min server memory (MB)');
| What you see | Meaning |
|---|---|
process_physical_memory_low = 1, OS available memory low | Windows or Linux is short of memory; something outside SQL Server may be using it |
max server memory = 2147483647 | Never configured; SQL Server competes with the OS and other processes |
Pool name is not default or internal | A Resource Governor pool hit its MAX_MEMORY_PERCENT |
OS has memory free, process memory near max server memory | One clerk inside SQL Server is taking too much |
2. Which memory clerk is the biggest?
SELECT TOP (15)
type,
SUM(pages_kb) / 1024 AS mb
FROM sys.dm_os_memory_clerks
GROUP BY type
ORDER BY mb DESC;
MEMORYCLERK_SQLBUFFERPOOL at the top is normal. Anything else taking a large share is your lead.
3. Did the resource monitor report low memory?
SELECT TOP (20)
DATEADD(ms, rb.[timestamp] - si.ms_ticks, SYSDATETIME()) AS event_time,
CAST(rb.record AS xml).value('(//Notification)[1]', 'varchar(50)') AS notification,
CAST(rb.record AS xml).value('(//IndicatorsProcess)[1]', 'int') AS process_ind,
CAST(rb.record AS xml).value('(//IndicatorsSystem)[1]', 'int') AS system_ind
FROM sys.dm_os_ring_buffers AS rb
CROSS JOIN sys.dm_os_sys_info AS si
WHERE rb.ring_buffer_type = N'RING_BUFFER_RESOURCE_MONITOR'
ORDER BY rb.[timestamp] DESC;
RESOURCE_MEMPHYSICAL_LOW with system_ind set points at OS pressure. With process_ind set, the pressure is inside SQL Server.
Common causes and fixes
| Top clerk or signal | Likely cause | Fix |
|---|---|---|
CACHESTORE_SQLCP very large | Thousands of single-use ad hoc plans | Enable optimize for ad hoc workloads, parameterise the app, clear SQL plans |
MEMORYCLERK_XTP | Memory-optimized tables or table variables grew past the pool limit | Bind the database to its own pool with enough memory, delete or archive rows |
OBJECTSTORE_LOCK_MANAGER | Millions of row locks from one large transaction | Batch the DML, find and stop the transaction |
MEMORYCLERK_SQLQERESERVATIONS | Huge memory grants from sorts and hashes | Fix the query or cap grants with Resource Governor |
MEMORYCLERK_SQLCLR, MEMORYCLERK_HOST | CLR assemblies or in-process linked server providers | Restart or move the provider out of process, fix the CLR code |
USERSTORE_TOKENPERM large | Security token cache growth | Check for a known issue on your build; apply the latest CU |
| Custom pool name in the error | MAX_MEMORY_PERCENT set too low | Raise the limit or move the workload |
Clerk names vary between versions; check the full list your build returns rather than relying on this table alone.
Plan cache bloat
SELECT objtype,
COUNT(*) AS plans,
SUM(CAST(size_in_bytes AS bigint)) / 1048576 AS mb,
SUM(CASE WHEN usecounts = 1 THEN 1 ELSE 0 END) AS single_use
FROM sys.dm_exec_cached_plans
GROUP BY objtype
ORDER BY mb DESC;
If Adhoc dominates and most plans are single use:
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'optimize for ad hoc workloads', 1; RECONFIGURE;
-- Clears only the ad hoc and prepared plan cache store
DBCC FREESYSTEMCACHE ('SQL Plans');
Warning
DBCC FREEPROCCACHEwith no arguments clears every plan on the instance. Expect a CPU spike while plans recompile. PreferDBCC FREESYSTEMCACHE ('SQL Plans')or remove one plan by itsplan_handle.
For a permanent fix, change the application to use parameterised queries, or set PARAMETERIZATION FORCED on the database after testing.
In-Memory OLTP
-- Run in the affected database
SELECT OBJECT_NAME(object_id) AS table_name,
memory_used_by_table_kb / 1024 AS table_mb,
memory_used_by_indexes_kb / 1024 AS index_mb
FROM sys.dm_db_xtp_table_memory_stats
ORDER BY memory_used_by_table_kb DESC;
Memory-optimized data cannot be paged out. When it fills the pool, inserts fail with 701 (or error 41805 on some operations). Give the database its own pool:
CREATE RESOURCE POOL Pool_Xtp WITH (MIN_MEMORY_PERCENT = 40, MAX_MEMORY_PERCENT = 40);
ALTER RESOURCE GOVERNOR RECONFIGURE;
EXEC sys.sp_xtp_bind_db_resource_pool @database_name = N'SalesDb', @pool_name = N'Pool_Xtp';
-- The binding takes effect after the database is taken offline and online again
Caution
Taking the database offline to apply the binding disconnects every session and, on large memory-optimized data sets, recovery can take a while. Schedule it and confirm free memory first, or the database may fail to come back online.
Lock memory from one transaction
SELECT TOP (10) request_session_id, COUNT(*) AS locks
FROM sys.dm_tran_locks
GROUP BY request_session_id
ORDER BY locks DESC;
Check what that session is running with sys.dm_exec_requests and sys.dm_exec_input_buffer(session_id, NULL). If you have to kill it, remember the rollback holds the locks until it completes.
Resource Governor pool limits
SELECT p.name, p.max_memory_percent,
s.used_memory_kb / 1024 AS used_mb,
s.target_memory_kb / 1024 AS target_mb
FROM sys.resource_governor_resource_pools AS p
JOIN sys.dm_resource_governor_resource_pools AS s ON s.pool_id = p.pool_id;
If the failing pool is at its target, raise it:
ALTER RESOURCE POOL ReportingPool WITH (MAX_MEMORY_PERCENT = 40);
ALTER RESOURCE GOVERNOR RECONFIGURE;
Set max server memory properly
If max server memory was never set, leave room for the OS and anything else on the host (agents, SSIS, antivirus, other instances). A common starting point is to reserve roughly 10% of RAM or at least 4 GB for the OS, whichever is larger, then adjust from the Memory\Available MBytes counter.
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'max server memory (MB)', 114688; RECONFIGURE; -- example: 112 GB on a 128 GB host
This takes effect without a restart. On Azure SQL Managed Instance you cannot change it; scale up or reduce the workload.
Collect evidence before you clear anything, so you can find the root cause later:
DBCC MEMORYSTATUS;
Save the output with the clerk query results and the time of the error.
Last resort
If the instance keeps failing and you cannot find the consumer quickly, a planned failover (AG or FCI) or a service restart clears memory. It also clears the evidence and the plan cache, and on a standalone server it is an outage. Capture DBCC MEMORYSTATUS and the clerk query first.
Prevent it next time
- Set
max server memoryon every instance as part of the build standard. - Turn on
optimize for ad hoc workloadswhere single-use plans dominate. - Put memory-optimized databases in a dedicated resource pool sized for growth.
- Alert on error 701 in the error log (SQL Agent alert on message 701, or your monitoring tool's error log rule).
- Trend the top five memory clerks every 15 minutes into a table so the next incident has a baseline.
- Keep the instance on a current cumulative update; several memory leak fixes ship in CUs. Read the CU notes for your version.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get