usr/Clear-PsWorkingSet.ps1
Set-Alias -Name clpws -Value Clear-PsWorkingSet function Clear-PsWorkingSet { <# .SYNOPSIS Sets the minimum working set size for the specified process. .DESCRIPTION The working set of a process is the set of memory pages in the virual address space of the process that are currently resident in physical memory. These pages are available for an application to use without triggering a page fault. .EXAMPLE Clear-PsWorkingSet explorer .EXAMPLE (Get-Process).Where{$_.WorkingSet64 -gt 100Mb}.ForEach{Clear-PsWorkingSet $_.Id} .INPUTS System.Int32 System.String .OUTPUTS System.Boolean if successed otherwise null. #> [CmdletBinding()]param($PSBoundParameters) end { New-Delegate kernel32 { bool SetProcessWorkingSetSize([ptr, int, int]) } New-PsProxy $PSBoundParameters -Callback { !$_.Handle ? ( Write-Verbose "$($_.ProcessName) ($( $_.Id)): cannot clear working set." ) : ( "$($_.ProcessName) ($($_.Id )) : {0}" -f $kernel32.SetProcessWorkingSetSize.Invoke( $_.Handle, -1, -1 )) } } } Export-ModuleMember -Alias clpws -Function Clear-PsWorkingSet |