Tools to analyzing the memory footprint of native DLLs and assemblies loaded in a process?

依然范特西╮ 提交于 2019-12-20 18:25:10

问题


I have a process holding 130MB of memory according to task manager, with only 11MB of live .NET objects according to dotTrace so I am wondering what's happening with the other 120MB??

I'd need a tool to list assemblies and native DLLs loaded in a process, gets the size of the images in process, and, for each assembly, measure the memory footprint of the methods JITed.

ListDlls from SysInternal does partly that job. But it doesn't measure JITed code size and it just provides raw data. Ideally I'd like a UI to analyze and sum-up these data.

Recently, the Visual Studio team reported having done such analysis with the tool PerfView. This is stated in the blog post Visual Studio 11 Beta Performance Part #1, section: The Biggest VM Consumer - DLLs. Does someone has experience and feedback analyzing native Dlls and assemblies footprint with PerfView?

Except ListDlls and PerfView, would you recommend any other tool?


Ok, VMMAP advised by Simon Mourier seems to be the more suited tool for this task.

VMMAP shows that the bulk of working set memory goes into the Managed Stack (113MB in green below), so the problem is more related to .NET objects than unmanaged memory. The green saw tooth curve, is just a timeline of loading/unloading sessions. For some reasons, my first measures were quite wrong:
  • dotTrace tells me I have 41MB of .NET objects allocated,
  • WMMAP shows a working set of 180MB (task manager shows a similar number)
  • WMMAP shows 113MB of managed heap allocated by the GC. 90MB of this managed heap memory is in the working set:

So my plan is:

  1. Identify why the GC allocates 113MB of managed heap for 41MB of .NET objects? (are such numbers normal? is it due to high fragmentation?)
  2. Work on shrinking this 41MB set of .NET objects allocated!

回答1:


Since you mention sysinternals' ListDlls, there is another tool called Process Explorer that has tons of information, and is much much better than ListDlls (you want to make sure you have the latest versions that also has a lot of .NET information, supports 64-bit and 32-bit processes, etc.).

For each process, you can have a simultaneous views of unmanaged memory (private bytes et al.) and managed memory (GC collections, large object heap, etc.) displayed in columns or per process.

Another cool tool from sysinternals is VMMAP. It's a process memory analysis utility and shows a breakdown of different types of virtual and physical memory types.

As for you 120Mb question, you really want to check all unmanaged DLLs that are injected in your process and are not part of standard Windows installation or standard DLL set of processes. For such big size allocations, I would first track graphical components of course as they are notably known for allocation big chunks of memory (especially if you speak about a tool such as NDepend which is graphical). Process Explorer can also tracks the number of GDI and USER objects.

On the GDI topic, there is a free tool named GDIView available here that gives a details of GDI objects allocated per process.




回答2:


I recommend SciTech .NET Memory Profiler. The tool is primary aimed at profiling .NET memory usages, such as finding .NET memory leaks or identifying zones of heavy memory pressure. While not its main usage, it also has a simpler display of native memory, including JIT code size per loaded library. I'm sure you'll be able to find where those 120 MB come from with this kind of information.




回答3:


I use RedGate ANTS .NET Developer Bundle for these issues. Memory Profiler allows to identify memory leaks (like zombies objects) and to make snapshots of memory usage. You'll then be able to compare classes and instances between two snapshots. You can track down instance reference in a tree and easily view the top object who maintain the reference.

Besides, Performance Profiler provides code profiling to identify bottlenecks and CPU usage.

For years now, it helped us alot to find application problems within minutes.



来源:https://stackoverflow.com/questions/9793391/tools-to-analyzing-the-memory-footprint-of-native-dlls-and-assemblies-loaded-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!