- Error number
- 802
- Severity
- 17 (resource or software problem)
- State
- Not documented by Microsoft (not reproduced here)
- Product
- Microsoft SQL Server Database Engine
- Versions
- All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
- Category
- Memory
- Last reviewed
- 24 October 2026
On this page
What it means
Error 802 means SQL Server needed a free buffer in the buffer pool, the pool was full and could not grow any further, so the request that needed it failed.
The buffer pool is where SQL Server keeps data and index pages, and it also supplies memory to many other components. Microsoft's explanation of 802 is short: the buffer pool is full and cannot grow larger. That happens when SQL Server has reached its memory target (max server memory, or what Windows allows it) and cannot free buffers fast enough, for example because large memory grants, caches or locks hold the memory, or because Windows itself is short of memory.
Severity 17 means a resource ran out; the statement fails but the server keeps running. The message has no pool name or size in it, so it does not tell you who used the memory. Compare it with error 701, which names the resource pool: the two often appear together during the same memory shortage, and the same checks of memory clerks and grants apply. For 802, start by comparing SQL Server's target and total memory and seeing what is filling the buffer pool.
Common causes
- Max server memory set low for the workload, or other applications on the server leaving SQL Server too little memory to reach its target.
- Large query memory grants for sorts and hashes taking memory that would otherwise hold data pages.
- Large caches outside the data cache, such as a plan cache full of single-use plans or a lock manager holding millions of locks.
- Big scans of large tables that keep replacing the buffer pool contents, so pages cannot be freed fast enough during peaks.
Diagnose it
Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.
Has SQL Server reached its memory target?
SELECT RTRIM(object_name) AS object_name, RTRIM(counter_name) AS counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name IN (N'Target Server Memory (KB)', N'Total Server Memory (KB)',
N'Database Cache Memory (KB)', N'Granted Workspace Memory (KB)',
N'Memory Grants Pending', N'Page life expectancy')
AND (object_name LIKE N'%Memory Manager%' OR object_name LIKE N'%Buffer Manager%'); Total equal to Target means SQL Server is at its limit. A large Granted Workspace Memory or Memory Grants Pending above 0 points to query grants; a Page life expectancy that drops sharply during the errors shows the data cache being flushed.
Which databases fill the buffer pool?
This reads one row per buffer, so on servers with a lot of memory it takes a while; run it off-peak.
SELECT CASE database_id WHEN 32767 THEN N'(resource database)' ELSE DB_NAME(database_id) END AS database_name,
COUNT_BIG(*) * 8 / 1024 AS cached_mb,
SUM(CAST(is_modified AS int)) * 8 / 1024 AS dirty_mb
FROM sys.dm_os_buffer_descriptors
GROUP BY database_id
ORDER BY cached_mb DESC; One database holding most of the cache usually means large scans there; tuning those queries frees the most memory.
Which memory clerks outside the data cache are large?
SELECT TOP (10) type, SUM(pages_kb) / 1024 AS pages_mb
FROM sys.dm_os_memory_clerks
WHERE type <> N'MEMORYCLERK_SQLBUFFERPOOL'
GROUP BY type
ORDER BY pages_mb DESC; Clerks such as MEMORYCLERK_SQLQERESERVATIONS (query grants), CACHESTORE_SQLCP (ad hoc plans) or OBJECTSTORE_LOCK_MANAGER (locks) far above normal are taking memory from the data cache.
Is Windows short of memory, and how is SQL Server configured?
SELECT total_physical_memory_kb / 1024 AS total_mb,
available_physical_memory_kb / 1024 AS available_mb,
system_memory_state_desc
FROM sys.dm_os_sys_memory;
SELECT name, value_in_use
FROM sys.configurations
WHERE name IN (N'max server memory (MB)', N'min server memory (MB)', N'min memory per query (KB)'); Low available memory means pressure from outside SQL Server. Note the three settings Microsoft asks you to check, and any value that is unusual for the server size (2147483647 for max server memory is the default, no limit).
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Reduce what fills the buffer pool
Client or network sideTune the queries behind the largest scans and memory grants: add or fix indexes so they read fewer pages, keep statistics current so grants are sized correctly, and avoid sorting or hashing more rows than needed. Parameterise ad hoc queries if the plan cache is large, and shorten transactions that hold many locks.
Remove pressure from outside SQL Server
Client or network sideIf diagnostics show Windows is low on memory, stop or move the other applications and services on the server, as Microsoft suggests, and make sure a virtual machine's memory is reserved rather than overcommitted.
Review memory settings, but only after measuring
Changes configurationMicrosoft suggests increasing max server memory if it was set. Do that only from measurements: what Windows and other processes need, and what SQL Server uses at peak. A higher limit with no free RAM only moves the shortage to Windows. If the workload simply needs more memory, the lasting fix is more RAM.
Caution: sp_configure and RECONFIGURE change the whole instance at once. Too high a max server memory starves Windows; too low starves every database. Record the old value so you can revert, and apply it in a maintenance window.
-- Only with a value chosen from measurements (example: 28 GB on a 32 GB server)
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'max server memory (MB)', 28672;
RECONFIGURE;
Examples
A large report fails during a memory shortage
Shown as documented by Microsoft; not reproduced here because it needs the buffer pool to be full on the whole instance. The query that fails is usually a victim. The level and state a client sees were not observed in the lab, so only the message text is shown; the catalogue severity is 17.
SELECT o.CustomerId, COUNT(*) AS Orders
FROM dbo.Orders AS o
JOIN dbo.OrderLines AS l ON l.OrderId = o.OrderId
GROUP BY o.CustomerId;
There is insufficient memory available in the buffer pool.
How to prevent it
Watch Target and Total Server Memory, Page life expectancy and Memory Grants Pending over time, so the point where SQL Server runs at its limit is visible before queries fail. Keep a baseline of the memory clerks to spot one that grows.
Leave memory for Windows and anything else on the server, set max server memory deliberately from those measurements, and tune the queries that scan the most pages or ask for the largest grants.
Common questions
Microsoft lists DBCC FREEPROCCACHE and FREESYSTEMCACHE. Should I run them?
Only as a temporary measure. They free cache memory for a moment, but every query has to compile again and the shortage returns. Find and reduce the consumer instead.
What is the difference between 802 and 701?
Both mean memory ran out. 802 is specifically the buffer pool being full and unable to grow; 701 names the resource pool where an allocation failed. They often appear in the same incident.
Does a low Page life expectancy mean I need more RAM?
Not on its own. It often means a few queries scan far more data than they need. Tune those first, then decide on memory from measurements.
Learn more on CodeWithSQL
Official documentation
Last technically reviewed 24 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.