Task Manager shows sqlservr.exe using 95% of the server's RAM. Someone restarts the service, memory drops, and a day later it's back at 95%. Is SQL Server leaking memory?
Almost certainly not. Taking the memory is by design. Leaving it unlimited is the mistake.
Why SQL Server takes all the memory
SQL Server caches data pages in the buffer pool. Reading a page from memory is thousands of times faster than reading it from disk, so SQL Server keeps every page it reads for as long as it can and grows the cache until it hits a limit. It deliberately doesn't give memory back just because it's idle; that memory is the cache.
The limit is max server memory, and its default is 2147483647 MB. In other words, all of it. On a dedicated database server that's close to what you want, but without a limit, SQL Server can squeeze the operating system, backup agents, antivirus and anything else on the box until Windows starts paging. That's when performance collapses.
Restarting "fixes" it only because it empties the cache. Every query then reads from disk until the cache warms up again. Please don't schedule restarts.
Set max server memory
Current guidance from Microsoft (updated in 2025) is a sensible starting point: about 75% of the memory not used by other processes, and leave min server memory at its default of 0 unless you have a specific reason.
| Server RAM | Starting max server memory |
|---|---|
| 16 GB | ~12 GB |
| 64 GB | ~48–52 GB |
| 256 GB | ~200–220 GB |
On larger servers you can move toward leaving a fixed amount (for example 8–16 GB) for the OS rather than a flat 25%. The setup program has suggested a value since SQL Server 2019.
EXEC sys.sp_configure N'show advanced options', 1;
RECONFIGURE;
EXEC sys.sp_configure N'max server memory (MB)', 49152; -- 48 GB
RECONFIGURE;
The change takes effect immediately with no restart. If you lower it, SQL Server releases memory gradually.
Several instances on one server? Give each one its own limit, and make sure the total leaves room for the OS. Leave extra headroom for SSIS, SSAS, SSRS or application services running on the same machine.
Memory outside the limit
max server memory covers the buffer pool, plan cache and most other caches, but not everything. Thread stacks, some CLR allocations, linked-server providers, third-party DLLs and (on older versions) some backup buffers are allocated outside it. Seeing sqlservr.exe use somewhat more than the setting is normal.
Is it actually under memory pressure?
High usage is fine. Pressure is what matters. Check these:
-- How long a page stays in the buffer pool (higher is better)
SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name IN (N'Page life expectancy', N'Memory Grants Pending');
-- Is SQL Server itself flagged as low on memory?
SELECT physical_memory_in_use_kb / 1024 AS in_use_mb,
process_physical_memory_low, process_virtual_memory_low
FROM sys.dm_os_process_memory;
-- What the OS thinks
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;
Warning signs:
- Memory Grants Pending > 0 for sustained periods: queries are waiting for workspace memory to run sorts and hashes. Look for oversized grants from bad estimates, or
RESOURCE_SEMAPHOREwaits. - Page life expectancy drops sharply during business hours: something is scanning large tables and pushing the cache out. That's usually a missing index, not a lack of RAM.
system_memory_state_desc= "Available physical memory is low": your max setting is too high for this box.
Lock pages in memory
On a dedicated server, granting the SQL Server service account the Lock pages in memory right stops Windows from paging the buffer pool out under pressure. Only do it after setting max server memory. Locked pages plus an unlimited max is how you starve the OS.
Checklist
- SQL Server using lots of memory is normal. Having no limit isn't.
- Set
max server memoryto about 75% of the memory not used by other processes, and leaveminat 0. - Judge pressure by Memory Grants Pending, PLE trends and the OS memory state, not by Task Manager.
- Fix scans and oversized memory grants before adding RAM, and never schedule restarts to "free memory".
Get the weekly commit
New database deep dives every week.
