Created
May 13, 2022 16:26
-
-
Save Otterpohl/38e1df27e74425df5a0246673b77c42c to your computer and use it in GitHub Desktop.
Calculate and set the max memory allocation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @OS_TotalMemory INT | |
,@OS_CPUCount INT | |
,@OS_Reserved INT | |
,@SQL_MAlloc INT | |
SELECT @OS_TotalMemory = CAST(total_physical_memory_kb AS INT) / 1024 / 1024 FROM sys.dm_os_sys_memory | |
SELECT @OS_CPUCount = cpu_count FROM sys.dm_os_sys_info | |
SELECT @OS_Reserved = 4 | |
SELECT @SQL_MAlloc = ((@OS_TotalMemory - (@OS_CPUCount * 0.5) - @OS_Reserved) - (@OS_TotalMemory - (@OS_CPUCount * 0.5) - @OS_Reserved) % 2) * 1024 | |
EXEC sp_configure 'max server memory', @SQL_MAlloc | |
RECONFIGURE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment