[DllImport("psapi")]
public static extern bool EmptyWorkingSet(long hProcess);
'Sorry - not tested yet
None.
System.Diagnostics.Process.MaxWorkingSet and System.Diagnostics.Process.MinWorkingSet are similar but are used to set thresholds rather than just free whatever can be freed.
Please add some!
public static bool TrimWSByProcess(Process process)
{
bool _result = false; //assume failed
try
{
if (process != null)
{ //only continue if we have a process
long _workingSet = process.WorkingSet64;
//trim working set
_result = PsapiHelper.EmptyWorkingSet((long)process.Handle);
//check result
if (_result)
{ //sucessfully trimed
}
else
{ //failed to trim
}
}
else
{ //no process passed in
}
}
catch (Exception ex)
{ //exception occured. Do some error handling
_result = false;
throw; //throw the error in this case.
}
return _result;
}