Is it possible to obtain summary information for managed objects on the heap in WINDBG that's similar to the summary presented by Visual Studio Ultimate's 'Debug Managed Memory' option.
I can obtain some of the information, but it's on a case by case basis, and is quite tedious. Is there a macro or set of commands that can produce similar output using WINDBG?
Visual Studio seems to have a neat little routine where it collects all the roots and shows a summary of the root object classes and their total memory.
These would get you the managed Memory, Heap Summary and Heap Consumption for specific types and just in case you are trying to find strings on the heap:
This will let you have a bin file which can be used in CLRProfiler:
For more refer to SOS Help. sosex is another extension but I not used it to debug leaks. CLRProfiler and Visual Studio Standalone Profiler are the best tools to debug these issues than Windbg IMHO.
Like for any .NET issue, you'll first need the SOS extension
You can then get a list of objects using
To get the inclusive size, you can use
To find the root of an object, use
Note that IMHO there is no convenient way of showing all root objects.
I'm not sure if Visual Studio lists objects on the stack. In WinDbg this would be
Example walkthrough:
So it seems that this object has no more references and will be garbage collected during next GC.