I have a heap corruption in a .NET/C# program and cannot track it with WinDbg + PageHeap + Application Verifier. In the next step, I plan to use Managed Debugging Assistants (MDAs).
Currently I try using these MDAs:
<gcManagedToUnmanaged />
<gcUnmanagedToManaged />
<invalidVariant />
(Having these MDAs enabled make开发者_如何学编程s the program run very slowly.)
Are there any other I can try in this case?
As Hans Passant pointed out, the primary MDA for such cases would be <gcUnmanagedToManaged>
. However, this MDA makes the program run very slow. Actually, the program becomes unusable (it takes "forever" to draw the program interface), thus it won't work in production. Visually this MDA is as slow as GCStress.
Other useful MDAs (work must faster):
<callbackOnCollectedDelegate />
<invalidOverlappedToPinvoke />
<overlappedFreeError />
To learn more about available MDAs and their detailed description, refer to the MSDN article Diagnosing Errors with Managed Debugging Assistants.
A good article on how to set MDAs for a program is Managed Debugging Assistants in .NET 2.0.
And finally, how to activate MDAs in the system, see Stack Overflow question .NET/C#: How to set debugging environment variable COMPLUS_HeapVerify?.
Try one of the commercial tools such as Red Gate's ANT's Memory Profiler or Jetbrain's DotTrace. I use ANTs Memory Profiler and was able to detect the memory leaks and fix the code that was causing the memory leaks, which may eventually lead to heap corruption. Here is an article on finding memory leaks using ANTs Memory Profiler
精彩评论