patternsqlMinor
Total Memory used by SQL Server (64 bit)
Viewed 0 times
totalbitsqlusedmemoryserver
Problem
My knowledge on the subject suggests that perf counter SQL Server:Memory Manager: Total Server Memory only gives you buffer pool memory. There is a column called physical_memory_in_use in a DMV named sys.dm_os_process_memor that gives you physical working set.
But I am not sure ...
is there a DMV or perf counter that could tell me total (buffer pool +
non buffer pool i.e. MemToLeave) physical memory used by SQL Server
process for 64 bit SQL Server 2008 R2 and SQL 2012 running on 64 bit
Windows OS?
But I am not sure ...
is there a DMV or perf counter that could tell me total (buffer pool +
non buffer pool i.e. MemToLeave) physical memory used by SQL Server
process for 64 bit SQL Server 2008 R2 and SQL 2012 running on 64 bit
Windows OS?
Solution
I'm not sure about a single view for memory, but you can get the information from two queries. The first (taken from Glenn Berry's DMV queries) leverages sys.dm_os_buffer_descriptors and will show you buffer pool by database:
The second query I put together by looking at sys.dm_os_memory_cache_entries to show me non-buffer pool information:
There are a host of DMVs related to memory, notated by
SELECT
DB_NAME(database_id) AS [Database Name]
,CAST(COUNT(*) * 8/1024.0 AS DECIMAL (10,2)) AS [Cached Size (MB)]
FROM sys.dm_os_buffer_descriptors WITH (NOLOCK)
WHERE database_id not in (1,3,4) -- system databases
AND database_id <> 32767 -- ResourceDB
GROUP BY DB_NAME(database_id)
ORDER BY [Cached Size (MB)] DESC OPTION (RECOMPILE);The second query I put together by looking at sys.dm_os_memory_cache_entries to show me non-buffer pool information:
select
name
,sum(pages_allocated_count)/128.0 [Cache Size (MB)]
from sys.dm_os_memory_cache_entries
where pages_allocated_count > 0
group by name
order by sum(pages_allocated_count) descThere are a host of DMVs related to memory, notated by
dm_os_memory_*. You can use these to investigate how memory is used by SQL Server on a variety of levels.Code Snippets
SELECT
DB_NAME(database_id) AS [Database Name]
,CAST(COUNT(*) * 8/1024.0 AS DECIMAL (10,2)) AS [Cached Size (MB)]
FROM sys.dm_os_buffer_descriptors WITH (NOLOCK)
WHERE database_id not in (1,3,4) -- system databases
AND database_id <> 32767 -- ResourceDB
GROUP BY DB_NAME(database_id)
ORDER BY [Cached Size (MB)] DESC OPTION (RECOMPILE);select
name
,sum(pages_allocated_count)/128.0 [Cache Size (MB)]
from sys.dm_os_memory_cache_entries
where pages_allocated_count > 0
group by name
order by sum(pages_allocated_count) descContext
StackExchange Database Administrators Q#41599, answer score: 3
Revisions (0)
No revisions yet.