进程内存大小 - 不同的计数器 [英] Process Memory Size - Different Counters

查看:261
本文介绍了进程内存大小 - 不同的计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出多少内存我自己的.NET服务器进程正在使用(用于监控和日志记录)。

I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes).

我使用的是:

Process.GetCurrentProcess().PrivateMemorySize64

不过,进程对象有几个是让我读使用的存储空间不同的属性: 分页,未分页,PagedSystem,NonPagedSystem,私人,虚拟,工作集

However, the Process object has several different properties that let me read the memory space used: Paged, NonPaged, PagedSystem, NonPagedSystem, Private, Virtual, WorkingSet

,然后在峰:我猜只是存储这些最后的曾任最大值

and then the "peaks": which i'm guessing just store the maximum values these last ones ever took.

通读每个属性的MSDN的定义尚未证明对我来说太有帮助。我不得不承认我对于内存是如何管理的(据分页和虚拟云)是非常有限的知识。

Reading through the MSDN definition of each property hasn't proved too helpful for me. I have to admit my knowledge regarding how memory is managed (as far as paging and virtual goes) is very limited.

所以我的问题显然是我应该使用哪一个?,我也知道答案是看情况。

So my question is obviously "which one should I use?", and I know the answer is "it depends".

这个过程基本上都会举行一堆会在事情内存名单,而其他进程与它沟通,并查询它的东西。我期待服务器在哪里,这将运行需要大量的内存,并且相比,它使内部列表的大小所以我查询这个数据随着时间的推移能够估计RAM的需求。

This process will basically hold a bunch of lists in memory of things that are going on, while other processes communicate with it and query it for stuff. I'm expecting the server where this will run on to require lots of RAM, and so i'm querying this data over time to be able to estimate RAM requirements when compared to the sizes of the lists it keeps inside.

所以...哪一个我应该使用,为什么?

So... Which one should I use and why?

推荐答案

如果你想知道有多少GC使用try:

If you want to know how much the GC uses try:

GC.GetTotalMemory(true)

如果你想知道你的进程使用从Windows(在任务管理器VM大小列)尝试:

If you want to know what your process uses from Windows (VM Size column in TaskManager) try:

Process.GetCurrentProcess().PrivateMemorySize64

如果你想知道你的程序在RAM(如页面文件反对)(在任务管理器内存使用列)尝试:

If you want to know what your process has in RAM (as opposed to in the pagefile) (Mem Usage column in TaskManager) try:

Process.GetCurrentProcess().WorkingSet64

请参阅这里更多解释上的不同各种各样的记忆。

See here for more explanation on the different sorts of memory.

这篇关于进程内存大小 - 不同的计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆