I am trying to understand the memory management of SQL Server. I have a Windows Server 2019 on virtual environment with 64 GB of RAM. I also have SQL Server 2019 installed with Max Server Memory 59776 MB. By using the following query I found the list of all memory clerks:
SELECT [type] AS [ClerkType], SUM(pages_kb) / 1024 AS [SizeMb] FROM sys.dm_os_memory_clerks WITH (NOLOCK) GROUP BY [type] ORDER BY SUM(pages_kb) DESC
Total sum of all memory clerks was equal to 23523 MB.
Value for MEMORYCLERK_SQLBUFFERPOOL memory clerk is 18387 MB.
I also checked some performance counters:
Total Server Memory (KB) = 32262 MB. Database Cache Memory (KB) = 18387 MB.
Please correct me if any of the below statements are wrong,
Max Server Memory for SQL Server 2019 = Buffer Pool Memory + Non-Buffer Pool Memory. Total Server Memory (KB) - The committed memory from the Buffer Pool. Data Cache Memory (KB) performance counter is equivalent to MEMORYCLERK_SQLBUFFERPOOL memory clerk and both represents data cache used size. Above query shows all memory clerks for both Buffer Pool Memory and Non-Buffer Pool Memory.
My question related to this subject:
If Total Server Memeory (KB) is related to Buffer Pool memory, then why its size (32262 MB) is bigger than Total sum memory clerks altogether (23523 MB) which represents both Buffer Poll Memory and Non-Buffer Pool Memory?