如何计算内存使用任务管理器呢?任务管理器、内存

2023-09-03 11:01:41 作者:不俗可人儿

好了,所以我使用WMI(.NET / C#),不断收集有关程序在计算机上运行的特定进程的数据。我通过Win32_PerfFormattedData_PerfProc_Process类。这个类有很多的属性,但那些我们感兴趣的是:

Ok so I am using WMI (.net/C#) to constantly collect data about a specific process that is running on the machine. I get the data through Win32_PerfFormattedData_PerfProc_Process class. That class has a lot of properties but those that we are interested in are as follows:

  uint64 PageFileBytes;

值,以字节为单位,这个过程已经在分页文件(S)使用。所使用的未包含在其他文件中的过程中的内存分页文件存储的页面。分页文件由空间的所有进程和缺乏分页文件共享可以从$分配内存不足p $ pvent等工序。

Value, in bytes, that this process has used in the paging file(s). Paging files store pages of memory used by the process that are not contained in other files. Paging files are shared by all processes and lack of space in paging files can prevent other processes from allocating memory.

  uint32 PoolNonpagedBytes;

值,以字节为单位,在非分页池,对于不能被写入磁盘的对象系统内存(使用的操作系统的物理内存)的一个区域,而是必须保留在物理内存中,只要它们被分配。在Win32_PerfFormattedData_PerfOS_Memory的PoolNonpagedBytes的计算方法不同比Win32_PerfFormattedData_PerfProc_Process的PoolPagedBytes属性,所以它可能不是PoolPagedBytes等于总的Win32_PerfFormattedData_PerfProc_Process的所有实例。此属性显示只有最后一个观察值;它不是一个平均

Value, in bytes, in the nonpaged pool, an area of system memory (physical memory used by the operating system) for objects that cannot be written to disk, but must remain in physical memory as long as they are allocated. The PoolNonpagedBytes in Win32_PerfFormattedData_PerfOS_Memory is calculated differently than the PoolPagedBytes property in Win32_PerfFormattedData_PerfProc_Process, so it might not equal the total of PoolPagedBytes for all instances of Win32_PerfFormattedData_PerfProc_Process. This property displays the last observed value only; it is not an average.

  uint32 PoolPagedBytes;

值,以字节为单位,在分页池,当不被用于该可写入磁盘对象系统存储器(所使用的操作系统的物理存储器)的一个区域他们。在Win32_PerfFormattedData_PerfOS_Memory的PoolNonpagedBytes属性的计算方法不同比Win32_PerfFormattedData_PerfProc_Process的PoolPagedBytes属性,所以它可能不是PoolPagedBytes等于总的Win32_PerfFormattedData_PerfProc_Process的所有实例。此属性显示只有最后一个观察值;它不是一个平均

Value, in bytes, in the paged pool, an area of system memory (physical memory used by the operating system) for objects that can be written to disk when they are not being used. The PoolNonpagedBytes property in Win32_PerfFormattedData_PerfOS_Memory is calculated differently than the PoolPagedBytes property in Win32_PerfFormattedData_PerfProc_Process, so it might not equal the total of PoolPagedBytes for all instances of Win32_PerfFormattedData_PerfProc_Process. This property displays the last observed value only; it is not an average.

  uint64 PrivateBytes;

当前值,以字节为单位,这一进程已分配的不能与其他进程共享。

Current value, in bytes, that this process has allocated that cannot be shared with other processes.

  uint64 VirtualBytes;

当前大小,以字节为单位的虚拟地址空间的进程正在使用。使用虚拟地址空间不一定意味着使用相应的磁盘或主内存页面。虚拟空间是有限的,如果使用太多,进程可能会限制其加载库的能力。

Current size, in bytes, of the virtual address space that the process is using. Use of virtual address space does not necessarily imply corresponding use of either disk or main memory pages. Virtual space is finite and, by using too much, the process can limit its ability to load libraries.

  uint64 WorkingSet;

最大数量,以字节为单位,在工作集这个过程的任何时间点。工作组是一组内存页最近在进程中的线程感动。如果自由存储器中的计算机是高于阈值,页数被留在即使它们是不使用的方法的工作集。当自由存储器低于阈值,页从工作集修整。如果他们需要,他们是那么的软故障返回到工作集它们离开主内存前。

Maximum number, in bytes, in the working set of this process at any point in time. The working set is the set of memory pages touched recently by the threads in the process. If free memory in the computer is above a threshold, pages are left in the working set of a process even if they are not in use. When free memory falls below a threshold, pages are trimmed from working sets. If they are required, they are then soft-faulted back into the working set before they leave main memory.

我目前使用工作集字段报告进程的内存使用情况。然而,这并不配合什么任务管理器中显示。我试着用 PrivateBytes 但这不是正确了。的过程,该应用监视器是一个.NET过程(如果,在所有重要的),并它被报道由该应用使用至少的100Mbs比任务管理器表示在同一时间内存。

I am currently using the WorkingSet field to report the process' memory usage. However that does not align with what Task Manger is showing. I tried with PrivateBytes but that's not "correct" too. The process that the app monitors is a .NET process (if that matters at all) and it gets reported by the app to use at least 100MBs more memory than what Task Manager is showing at the same time.

所以,问题是什么是公式计算过程中的内存使用情况最好的近似如由任务管理器?

So the question is what is the "formula" to calculate the best approximation of process' memory usage as shown by Task Manager?

推荐答案

Win32_PerfFormattedData_PerfProc_Process 是正确的类。它拉的属性是 WorkingSetPrivate 。没有公式/计算需要的。

Win32_PerfFormattedData_PerfProc_Process is the correct class. The property it pulls from is WorkingSetPrivate. No formula/calculation needed.