What MDAs are useful to track a heap corruption?

2019-07-25 03:52发布

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 makes the program run very slowly.)

Are there any other I can try in this case?

2条回答
Ridiculous、
2楼-- · 2019-07-25 04:18

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?.

查看更多
\"骚年 ilove
3楼-- · 2019-07-25 04:20

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

查看更多
登录 后发表回答