『QQ:1353814576』

C#怎么通过 PerformanceCounter 实现 获取当前系统内存的占用率?


C# 通过 PerformanceCounter 实现 监控系统的内存占用百分比

代码如下:

System.Diagnostics.PerformanceCounter Counter = new System.Diagnostics.PerformanceCounter("Memory", "% Committed Bytes In Use");
var value = Counter.NextValue();//返回的就是当前系统内存的占用百分比

返回的结果时当前内存占用百分比 对应任务管理器的内存项(数值会有些许误差可忽略)