I am having an issue in my SQL Server like high memory paging rate and more compilation/sec which lead me to a different observation in memory, so first i checked what is total size of memory of system and what are the threshold levels set in SQL server i.e. min server memory 4096 MB and max server memory 51200 MB, i checked few performance counters total server memory is 64 GB, target server memory is 53 GB and other performance counters as shown below images
When i checked sys.dm_os_buffer_descripters in SQL Server there are very less dirty pages, but when i check total size of memory occupied by all databases is 39 GB as shown in below images
My questions is why and how 14 GB of memory is additionally being occupied by SQL Server and the same i can in resource monitor or performance counter like below image.
Can any one tell me did i miss some thing to check, Total databases are occupying only 39 GB but if i check perfmon or resource monitor it shows that SQL Server is occupying total 53 GB, how 14 GB can be used internally.
Best Answer
sys.dm_os_buffer_descriptors
From the official documentation on sys.dm_os_buffer_descriptors (Transact-SQL):
You are looking at the data cache usage. But there are more objects in memory than just the data.
sys.dm_exec_cached_plans
You have to consider the plan cache (sys.dm_exec_cached_plans (Transact-SQL)) and other objects.
Memory acquired by cached plans can be retrieved with the following script:
sys.dm_os_memory_clerks
But instead of looking at individual caches, you might want to consider querying the view: sys.dm_os_memory_clerks
sys.dm_os_memory_objects
Use the following query to see what sys.dm_os_memory_objects (Transact-SQL) are using in RAM.
Summary
So while sys.dm_os_buffer_descriptors does provide an overview of the data cahce, you will have to query other sys views to determine the actual current memory usage.
Your SQL Server instance may at one time have occupied 53 GB of RAM, but it is now only currently consuming 39 GB of RAM (in data cache) and more GB in plan cache and memory objects, which may sum up to 53 GB RAM, but which may also sum up to less because of free pages in RAM, that may not yet have been released by SQL Server.