I've got a service that has a very slow memory leak. If I analyze the .NET CLR Loading counters, I see that the Current Classes Loaded counter is constantly increasing and matches Total Classes Loaded counter at all times. This gives me the impression that the memory leak is related to resources not being freed (This is just a guess).
The service creates new appDomains each time it performs a task (plug-in architecture).
I need to figure out the class names so I can narrow down the cause of the leak. I'm not very proficient with WinDbg, but I was wondering if anyone could walk me through the steps to enumerate these Loaded classes.
I do have the source code so I can obtain the symbol files if necessary. Thanks in advance for any help!
Is this .net 2.0 or higher? If so, you may not be unloading the AppDomain
(as Jon Skeet says in the comment).
If it's 1.1 or lower, there is a bug in the AppDomain
unload functionality. I.e. it doesn't free up the memory or release resources when an AppDomain
is "unloaded".
(This was fixed as of .net 2.0)
You can always check what assemblies are loaded in your AppDomain:
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
Console.WriteLine(assembly.FullName);
}
So if you accidentally load the assemblies in the wrong domain it wont be hard too see.
Edit:
if you want to use WinDgb SOS, here are the supported commands. You're most likely interested in: DumpDomain, DumpClass, DumpAssembly, EEHeap ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With