在WPF中获取程序的专用工作集内存 PerformanceCounter
2015-12-04 17:17
253 查看
使用 PerformanceCounter 获取程序的专用工作集内存并不难,但是就是得找一下属性,
通过
遍历
再通过它们遍历
之后通过这三个属性得到我们想要的内存,
使用时:
通过
CategoryName
遍历
InsanceName
再通过它们遍历
CounterName
之后通过这三个属性得到我们想要的内存,
public class MemoryHelper { /// <summary> /// 性能计数器组件类 /// </summary> private static PerformanceCounter performanceCounter = null; /// <summary> /// 获取程序专有内存 /// </summary> /// <returns>专有内存</returns> public static int getPrivateMemory() { int result = 0; if (performanceCounter==null) { performanceCounter = new PerformanceCounter("Process", "Working Set - Private", Process.GetCurrentProcess().ProcessName); } result = (int)(Convert.ToInt64(performanceCounter.NextValue()) / 1024.0); return result; } }
使用时:
//获取专有工作集内存(例:119844[这里的单位是K]) int privateMemory = MemoryHelper.getPrivateMemory();
相关文章推荐
- 模糊测试相关文章
- DPDK编程指导——编写高效代码(翻译)
- Ansi、GB2312、GBK、Unicode(utf8、16、32)
- 点击头像单独把图片拉取出来.然后再次点击回到初始效果
- Echarts使用指南
- Php数组
- 从内存角度深入看结构体(window/linux)大小
- hdoj Calculate S(n) 2114 (数学规律 取余)
- C# 随机生成手机号码(中国地区)
- 广州的小伙伴福利-由微软组织的在广州SQL Server线下活动
- akka cluster make node as unreachable 问题
- react tab
- Xcode svn import项目 上传.a文件(静态库)
- EasyUI datagrid 获取全部数据
- Rose Study
- android 简单设置欢迎页面
- Python开发常用模块
- angular中compile和link的区别
- 【转】安装最新(较新)的node 和 npm
- 由于外键的存在引发的一个mysql问题 Cannot change column 'id': used in a foreign key constraint