There seems to be a discrepancy between the amounts reported in sys.dm_os_memory_clerks & sys.dm_exec_cached_plans.
The below 2 queries produce 2 very different amounts
--Query 1 - Shows 1171MB allocated SELECT TOP(20) [type], [name], SUM(single_pages_kb)/1024 AS [SPA Mem, Mb] FROM sys.dm_os_memory_clerks WHERE type = 'CACHESTORE_SQLCP' GROUP BY [type], [name] ORDER BY SUM(single_pages_kb) DESC;
--Query2 - Shows 291MB allocated SELECT sum(cast(size_in_bytes as decimal(18,2)))/1024/1024 AS [Total MBs] FROM sys.dm_exec_cached_plans where objtype in ('Adhoc', 'Prepared')
The 2 values should be the same, as far as I understand
Why am I seeing different values being reported?
Thanks