Which .NET performance and/or memory profilers will allow me to profile a DLL?

江枫思渺然 提交于 2019-12-12 04:28:13

问题


I write a lot of .NET based plug-ins for other programs which are usually compiled as a DLL which is up to the native application to start up. I've been using Equatec's profiler, which works great, but now would like something with more features, including the ability to profile memory usage.

I tried out Red Gate's Ant Profiler, but as far as I can see there is no way to profile a DLL. The only option is to profile an EXE.

So my question is what other profiling tools are available that will allow me to profile a single library DLL rather than an EXE. I'm assuming this would require injecting profile code into the library as Equatec does?


回答1:


.Net Memory Validator and .Net Performance Validator both allow you to profile just a dll.

You have to specify the DLLs you are interested in (or not interested in) in the "Hooked DLLs" part of the settings dialog. Then launch your application - only data from the specified DLL is collected.

Full disclosure: I am a software engineer at the company that creates these tools.




回答2:


Yes, that does work this way. A DLL is just a blob of code, it gets merged with the code in the EXE. A DLL cannot "own" any memory, an AppDomain does. You can however see how much time is spent in the code that came from a DLL.

If you write a test program that itself doesn't make any major memory allocations but does call the methods of the classes in the DLL then you can attribute the memory usage to the DLL without a problem. Writing such a test program and make it resemble the way the DLL code is used in a real program is however not that easy.




回答3:


This may no longer be relevant for you but I thought I'd put it out here for posterity, Redgate Ants profiler does allow you to profile a single dll using a custom filter:

http://www.red-gate.com/supportcenter/content/ANTS_Profiler/articles/profiling_single_dotnet_assembly

We set up performance profiling of "CoolApp" in the usual fashion, using the ANTS Profiler 3 project wizard. The final screen of the wizard is the point at which we can customize the project to restrict profiling to just one library. We specify that we want to use a Custom filter to limit the areas of the application that will be profiled.

We edit the custom filter and specify that we are only interested in profiling a particular namespace, as shown below. In this case, we set up a filter that will cause ANTS Profiler to only profile methods that are part of the RedGate.Library1 namespace. This is exactly what we want, and we are now ready to start profiling.

We can now proceed with profiling in the usual fashion. However, when we get performance profiling results, either by taking a snapshot, or by closing down the application, they will only contain data about methods in RedGate.Library1.dll.

Included text from the website in case that link ever goes dead.



来源:https://stackoverflow.com/questions/2430047/which-net-performance-and-or-memory-profilers-will-allow-me-to-profile-a-dll

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