Winform 获取程序专用内存
//内存分为专用工作集 和 共享工作集 ,此处为专用工作集,单位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;
}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。