Just because your application uses a lot of memory does not necessarily mean that you have a memory leak. From the information in your question, itโs hard to say what might be wrong.
When resolving a managed memory leak error using WinDbg, I do the following:
Get an overview of heap usage with !eeheap (this reports heap usage, not the stack, as you mention - each stack has a default size of 1 MB, so if you haven't changed this, you can use 100 MB on the stack)
Do !dumpheap -stat to find out what is in the heap. Most likely, if you have a memory leak, then the culpable types (s) will be among the best consumers. To understand how heap usage is evolving, you can resume your application, break it up a bit, and then repeat the !dumpheap -stat .
If you find any types with a large number of instances besides those that would be selected, list them with !dumpheap -mt <MT of type> . This list lists all instances of a particular type. Select random instances and check the roots with the !gcroot . This will tell you what keeps these examples alive. If there is no root, these instances will be collected at some point.
UPDATE to respond to your comments:
A managed heap is only part of the memory area of โโa managed application. Remember that a .NET application is really an application inside another application - a host process that loads the CLR, which in turn loads your application. Therefore, before your application starts using any memory, the CLR has already taken a fair share. Besides the fact that .NET applications store both MSIL code and JIT-compiled code as part of the print foot. The CLR also takes up space for various types of accounting (for example, the CLR creates two additional AddDomains for internal use).
The numbers you give do not hit me like the top, but since I do not know your application, it is difficult to say whether they are excessive.
100 MB on a managed heap might be fine, depending on what your application is doing. Have you checked a bunch? And if so, what did you find?
Brian rasmussen
source share