Export (0) Print
Expand All

gcManagedToUnmanaged MDA

The gcManagedToUnmanaged managed debugging assistant (MDA) causes a garbage collection whenever a thread transitions from managed to unmanaged code.

An unmanaged user component throws an access violation when trying to use a managed object that had been exposed to COM. The COM object appears to have been released. The access violation is nondeterministic.

If an unmanaged component is not reference counting a managed COM object correctly, then the runtime could collect a managed object exposed to COM when the unmanaged component still holds a reference to the object. The runtime calls Release during garbage collections, so if the user component uses the object before the garbage collection occurs, then it will not yet have been collected. This is the source of the nondeterminism.

Enabling this assistant reduces the time between when the object is eligible for collection and Release is called, helping to track down which unmanaged component first tries to access the collected object.

Causes a garbage collection whenever a thread transitions from managed to unmanaged code.

This MDA produces no output.

<mdaConfig>
  <assistants>
    <gcManagedToUnmanaged/>
  </assistants>
</mdaConfig>
Show:
© 2014 Microsoft