Examining the .NET heap at runtime
Is there any way to walk the heap from a .NET application? I 开发者_如何学编程have a Silverlight application and want to be able to examine the heap for memory leaks. I thought it would be nice to implement a debugging popup window that would display the contents of the heap. I have looked through the .NET API namespaces and can't find anything relevant.
You can use the SOS Debugging Extension to examine the managed memory allocations in your program.
Here is a blog post walking through how to do this with Silverlight.
You can also try the SysInternals's tool ProcessExplorer. It have a tab named .NET where you can find a lot of specific data about .NET applications (memory, garbage collector activity, etc). Every time I suspect that my code is leaking memory I use this tool to check and understand what is happening.
精彩评论