Created
February 22, 2024 09:19
-
-
Save Digiover/446df93ff8ddcd28d3f0dea4827b02f2 to your computer and use it in GitHub Desktop.
Add gcTrimCommitOnLowMemory runtime Aspnet configuration
This file contains hidden or 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
# https://www.saotn.org/aspnet-performance-what-to-keep-in-mind/#highdensitywebhosting | |
$bitness = @("64", "") | |
foreach ($bits in $bitness) { | |
$xml = New-Object xml | |
$xml.Load("C:\Windows\Microsoft.NET\Framework${bits}\v4.0.30319\Aspnet.config") | |
# Check whether the runtime control gcTrimCommitOnLowMemory is already registered | |
$nodeGcTrimCommitOnLowMemory = $xml.SelectSingleNode("configuration/runtime/gcTrimCommitOnLowMemory") | |
# Not registered, let's add gcTrimCommitOnLowMemory | |
if ($nodeGcTrimCommitOnLowMemory -eq $null) { | |
$parentNode = $xml.SelectSingleNode("configuration/runtime") | |
$childNode = $xml.CreateElement("gcTrimCommitOnLowMemory") | |
$childNode.SetAttribute("enabled", "true") | |
$parentNode.AppendChild($childNode) | |
} | |
$xml.Save("C:\Windows\Microsoft.NET\Framework${bits}\v4.0.30319\Aspnet.config") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget to reset IIS afterwards