未维护完整性,流程的“工作集"和“峰值工作集"值 [英] Integrity not maintained Working Set and Peak Working Set Values for a process

查看:121
本文介绍了未维护完整性,流程的“工作集"和“峰值工作集"值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[背景]

  1. 我正在使用.net下的System.Diagnostics.Process程序集进行跟踪 流程的绩效.
  2. 我以1秒的间隔采集30个样本
  3. 工作集的值填充为:
  1. I am using System.Diagnostics.Process assembly under .net to track the performance of a process.
  2. I am taking 30 samples at an interval of 1 sec
  3. Value of Working set populated as:

long peakWorkingSet = requiredProcess.PeakWorkingSet64其中

Process requiredProcess = Process.GetProcessesByName(processName).First();

  1. 使用与以下相同的流程实例填充的峰值工作集"的值:

long WorkingSet = requiredProcess.WorkingSet64

[查询]

我希望PeakWorkingSet64是由WorkingSet64表示的关联内存的峰值(如果我在这里输入错误,请更正)

I expect the PeakWorkingSet64 be the peak value of memory associated which is represented by WorkingSet64(Please correct if I am mistaken here)

但是由于某种原因,我发现PeakWorkingSet64的值为80K,而实际上样本数据表明WorkingSet64的值从未达到该值.它们在5万左右波动.

But for some reason, I see the value of PeakWorkingSet64 as 80K when in fact the sample data suggests values of WorkingSet64 never reached that value. They were fluctuating around 50K.

感谢任何输入.请帮助了解

Any inputs appreciated.Please help understand

推荐答案

不确定该说些什么(或者为什么我特别应该能够占卜).

Not sure what to say about that (or why I in particular should be able to divine).

PeakWorkingSet64确实具有WorkingSet64的整个历史记录的峰值,如

PeakWorkingSet64 indeed holds, as you expect, the peak value of the entire history of WorkingSet64 as specified in the MSDN docs:

自启动以来,为关联进程分配的最大物理内存量(以字节为单位).

The maximum amount of physical memory, in bytes, allocated for the associated process since it was started.

请注意,这表示自程序生成后开始",例如包括运行时初始化的时间段.

Note that this means "from since the process was spawned", which e.g. includes the period of time during which the runtime initializes.

现在,您已尝试通过以一秒钟的间隔获取少量(30)离散样本来测量内存消耗.这不是一种非常可靠的测量方法.从这些样本中您所知道的只是工作集在您看的准确时间上是什么样子,而不是前一刻或后一刻的样子.
当您每秒查看一次时,工作集可能总是在50kiB左右,但在两次采样之间的其他时间(或任何其他值)可能是80k.工作集不是恒定的,它们一直在变化.
此外,更有可能的是,在启动期间(即,甚至在执行代码之前!)工作集可能会更大.因此,峰值自然会更高,但是即使您进行一百万次采样,也永远无法用样品测量"出如此高的值.

Now, you have tried to measure the memory consumption by taking a small number (30) of discrete samples, in an interval of one second each. This is not a very reliable way of measuring. All you know from those samples is what the working set looked like at the precise time you looked at it, not what it looked like a moment earlier or a moment later.
The working set might incidentially always be around 50kiB when you look at it once per second, but might be 80k at another time (or any other value) in between the samples. Working sets are not constant, they change all the time.
Further, and more likely, the working set might be much larger during startup (that is, before your code is even executed!). Thus, the peak value would naturally be higher, but you never get to "measure" such a high value with your samples, even if you do a million samples.

这篇关于未维护完整性,流程的“工作集"和“峰值工作集"值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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