views:

127

answers:

2

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  A: 

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.

Hans Passant
A: 

.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.

Stephen Kellett