22,300
社区成员




DBCC FREEPROCCACHE
DBCC FREESESSIONCACHE
DBCC FREESYSTEMCACHE('All')
DBCC DROPCLEANBUFFERS
USE master
go
EXEC sp_configure 'show advanced options', 1
go
RECONFIGURE WITH OVERRIDE
-- 先设置物理内存上限到1G
EXEC sp_configure 'max server memory (MB)', 1024
RECONFIGURE WITH OVERRIDE
-- 还原原先的上限
EXEC sp_configure 'max server memory (MB)', 5120
RECONFIGURE WITH OVERRIDE
-- 恢复默认配置
EXEC sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
print @@version
Target Server Memory (KB) --服务器能够使用的动态内存总量。
Total Server Memory (KB) --从缓冲池提交的内存 (KB)。注意:这不是 SQL Server 使用的总内存。
select counter_name,
ltrim(cntr_value*1.0/1024/1024)+'G' as memoryGB
from master.sys.dm_os_performance_counters
where counter_name like '%target%server%memory%'or counter_name like '%total%memory%'
/*counter_name memoryGB
TargetServerMemory(KB) 0.21694946289G
TotalServerMemory(KB) 0.02523040722G */
counter_name memoryGB
Target Server Memory (KB) 0.21694946289G
Total Server Memory (KB) 0.02523040722G
select counter_name,
ltrim(cntr_value*1.0/1024/1024)+'G' as memoryGB
from master.sys.dm_os_performance_counters
where counter_name like '%target%server%memory%'or counter_name like '%total%memory%'
/*
counter_name memoryGB
-------------------------- -----------------
Target Server Memory (KB) 0.62960815429G
Total Server Memory (KB) 0.08227539062G
*/