Winform 獲取程序專用內存
阿新 • • 發佈:2018-10-16
inf info except counter public sta name sna turn //內存分為專用工作集 和 共享工作集 ,此處為專用工作集,單位KB
public static long PerformanceCounter()
{
long value = 0;
Process p = null;
try
{
p = Process.GetCurrentProcess();
var ps = Process.GetCurrentProcess();
PerformanceCounter pf1 = new PerformanceCounter("Process", "Working Set - Private", p.ProcessName);
value = (long)(pf1.NextValue() / 1024);
Console.WriteLine("PerformanceCounter--", value.ToString());
}
catch (Exception e)
{
Console.WriteLine("PerformanceCounter--", e.ToString());
}
finally { p?.Dispose(); }
return value;
}
public static long PerformanceCounter()
{
long value = 0;
Process p = null;
try
{
p = Process.GetCurrentProcess();
var ps = Process.GetCurrentProcess();
PerformanceCounter pf1 = new PerformanceCounter("Process", "Working Set - Private", p.ProcessName);
value = (long)(pf1.NextValue() / 1024);
}
catch (Exception e)
{
Console.WriteLine("PerformanceCounter--", e.ToString());
}
finally { p?.Dispose(); }
return value;
}
Winform 獲取程序專用內存