I'm trying to understand more about the memory usage for SQL Server. I can't seem to figure out what's exactly stored in the memory buffer. My setup is a Windows Server 2008 x64, 8 GB RAM, SQL Server 2008 standard R2, maximum SQL Server memory 6000 MB.
After running SQL Server a couple of hours, the resource monitor shows sqlservr.exe
has used about 6000 MB of memory, but when I check the usage for data and plan caches I get less than 6000 MB:
Cached plans 2541 MB
Database data cached 2706 MB
Total 5247 MB
I used sys.dm_exec_cached_plan
and sys.dm_os_buffer_descriptors
to find these values, so from these values I don't know what the 750 MB are used for… I don't think SQL Server is reserving memory since this is a x64 machine… Am I missing something here?
Best Answer
There are other memory consumers outside of the buffer pool. For instance, SQL Server will use memory for worker threads, multi-page allocations, linked servers, extended stored procedures, CLR, etc.
The buffer pool is never going to equate to 100% of memory consumed by SQL Server. It's a common misconception, as well as setting max memory will be the actual max memory SQL Server uses (not true).
EDIT: Here's how I think you could get non-buffer pool memory size. Note: wait for the input of other SQL Server professionals before taking this query as fact. I cannot guarantee that it is absolutely correct.