--強制釋放內存 CREATE procedure [dbo].ClearMemory as begin --清除所有緩存 DBCC DROPCLEANBUFFERS --打開高級配置 exec sp_configure 'show advanced options', 1 EXEC ('RECONFIGURE') --設置最大內存值,清除現有緩存空間 單位 MB exec sp_configure 'max server memory', 256 EXEC ('RECONFIGURE') --設置等待時間 WAITFOR DELAY '00:00:01' --重新設置最大內存值 單位 MB EXEC sp_configure 'max server memory', 4096 EXEC ('RECONFIGURE') --關閉高級配置 exec sp_configure 'show advanced options',0 EXEC ('RECONFIGURE') --下面提供內存查看功能的一些腳本語句: --內存使用情況 --SELECT * FROM sys.dm_os_performance_counters --WHERE counter_name IN ('Target Server Memory (KB)','Total Server Memory (KB)') -- 內存狀態 ;根據需要顯示,也可以不顯示 --DBCC MemoryStatus END --執行以下語句,釋放占用內存 EXEC ClearMemory