Physical memory and memory used by SQL Server
Two T-SQL queries that return the physical memory of the server and the memory used by SQL Server, in gigabytes.
Two queries that return the physical memory of the server, the memory committed by SQL Server, and the total server memory used by the SQL Server instance.
SELECT physical_memory_kb/1024.0/1024.0, committed_kb/1024.0/1024
FROM sys.dm_os_sys_info;
SELECT object_name, cntr_value/1024.0/1024.0
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Total Server Memory (KB)';
Reading the results
- The first query returns the physical memory of the server (
physical_memory_kb) and the committed memory (committed_kb), in gigabytes. - The second query returns the
Total Server Memory (KB)counter, converted from kilobytes to gigabytes. - Dividing by 1024 twice converts kilobytes to gigabytes.