[DllImport("psapi.dll")]
public static extern bool EmptyWorkingSet(IntPtr hProcess);
public FreeMem(string programName){
EmptyWorkingSet(Process.GetCurrentProcess().Handle);
foreach(Process process in Process.GetProcesses(programName))
{
try
{
EmptyWorkingSet(process.Handle);
}
catch (Exception)
{
...
}
}
}
没什么好补充的。慎重使用~