Perfmon计数器检查内存泄漏 [英] Perfmon counters to check memory leak

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

问题描述

我想检查服务中的内存泄漏问题.我尝试了以下perfmon计数器集.

  1. 所有堆中的.NET CLR内存\#字节
  2. .NET CLR内存\第二代堆大小
  3. .NET CLR内存\#GC句柄
  4. .NET CLR内存\#固定对象
  5. .NET CLR内存\#已提交的总字节数
  6. .NET CLR内存\#总保留字节
  7. .NET CLR内存\大对象堆大小

我已从此处

另请参阅以下设置:

  1. 内存/可用字节
  2. 内存/已提交字节
  3. 处理/专用字节
  4. 进程/页面文件字节
  5. 处理/处理计数

我已从此处

是否有任何参数/标准或其他最佳方法来标识用于内存泄漏的性能计数器?
有人可以建议我设置一组计数器来检查内存泄漏吗?或以上设置涵盖了内存泄漏?

解决方案

要使用性能监视器检测内存泄漏,请监视以下计数器:

  1. 内存/可用字节数"计数器使您可以查看可用内存的字节总数.该值通常会波动,但是如果 您有内存泄漏的应用程序,它将减少 时间.
  2. 如果发生内存泄漏,则"Memory/Committed Bytes"计数器将稳定增加,因为随着 内存减少,提交的字节数增加.
  3. 进程/专用字节数"计数器显示专门为特定进程保留的字节数.如果是内存泄漏 发生时,该值将趋于稳定上升.
  4. 进程/页面文件字节数"计数器显示页面文件的大小. Windows使用虚拟内存(页面文件)来补充 机器的物理内存.随着机器的物理内存开始 填满后,内存页面将移至页面文件.这是正常的 即使在具有大量内存的计算机上也要使用的页面文件.但 如果页面文件的大小稳定增加,则表明 发生内存泄漏.
  5. 我还想提到处理/处理计数"计数器.应用程序使用句柄来标识他们必须使用的资源 使用权.如果发生内存泄漏,应用程序通常会 创建其他句柄以标识内存资源.所以上升 句柄计数可能表示内存泄漏.但是,并非全部 内存泄漏将导致句柄数增加.

来源

根据我的经验,这是正确的.

我还将推荐您访问Microsoft员工Tess的这个Microsoft Advanced Debugging博客.谁建议以下计数器.我发现以上内容足以表明存在内存泄漏,但是我相信Tess的说明可以提供对该问题的更深入了解.

调试演示-内存查看

  • .NET CLR内存/所有堆中的#个字节
  • .NET CLR内存/大对象堆大小
  • .NET CLR内存/第二代堆大小
  • .NET CLR内存/第1代堆大小
  • .NET CLR内存/第0代堆大小
  • 处理/专用字节
  • 进程/虚拟字节

I want to check the memory leakage issue in my service. I have tried following set of perfmon counters.

  1. .NET CLR Memory\# Bytes in all Heaps
  2. .NET CLR Memory\Gen 2 Heap Size
  3. .NET CLR Memory\# GC handles
  4. .NET CLR Memory\# of Pinned Objects
  5. .NET CLR Memory\# total committed Bytes
  6. .NET CLR Memory\# total reserved Bytes
  7. .NET CLR Memory\Large Object Heap size

I have referred above set from here

Also referred following set:

  1. Memory/Available Bytes
  2. Memory/Committed Bytes
  3. Process/Private Bytes
  4. Process/Page File Bytes
  5. Process/Handle Count

I have referred above set from here

Is there any parameter/criteria or any other best way to identify perfmon counter for memory leak?
Can any one suggest me set of counters to check memory leak? Or above sets covers memory leak?

解决方案

To detect a memory leak using Performance Monitor, monitor these counters:

  1. The Memory/Available Bytes counter lets you view the total number of bytes of available memory. This value normally fluctuates, but if you have an application with the memory leak, it will decrease over time.
  2. TheMemory/Committed Bytes counter will steadily rise if a memory leak is occurring, because as the number of available bytes of memory decreases, the number of committed bytes increases.
  3. The Process/Private Bytes counter displays the number of bytes reserved exclusively for a specific process. If a memory leak is occurring, this value will tend to steadily rise.
  4. The Process/Page File Bytes counter displays the size of the pagefile. Windows uses virtual memory (the pagefile) to supplement a machine's physical memory. As a machine's physical memory begins to fill up, pages of memory are moved to the pagefile. It is normal for the pagefile to be used even on machines with plenty of memory. But if the size of the pagefile steadily increases, that's a good sign a memory leak is occurring.
  5. I also want to mention the Process/Handle Count counter. Applications use handles to identify resources that they must access. If a memory leak is occurring, an application will often create additional handles to identify memory resources. So a rise in the handle count might indicate a memory leak. However, not all memory leaks will result in a rise in the handle count.

Source

In my experience this is accurate.

I'd also refer you to this Microsoft Advanced Debugging blog by Tess, a Microsoft employee. Who suggests the following counters. I have found the above to be more than enough to indicate a memory leak is present but I trust that Tess's instructions could provide a more indepth insight into the issue.

Debugging Demos - Memory Review

  • .NET CLR Memory/# Bytes in all Heaps
  • .NET CLR Memory/Large Object Heap Size
  • .NET CLR Memory/Gen 2 heap size
  • .NET CLR Memory/Gen 1 heap size
  • .NET CLR Memory/Gen 0 heap size
  • Process/Private Bytes
  • Process/Virtual Bytes

这篇关于Perfmon计数器检查内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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