views:

269

answers:

1

I have a mixed managed/unmanaged environment (Visual Studio and ReSharper) and I suspect CCW or RCW leak. Is there any way to dump all currently allocated wrappers and identify their source/target? I have WinDbg, SOS & SOSEx, so I can see total number of RCWs and CCWs with !syncblk command. I just want to see objects, so I can call !gcroot on them and otherwise examine suspects.

+1  A: 

You should be able to use !dumpheap to do this. !dumpheap -stat would let you find the type names (if you don't already know them) and then !dumpheap -type {typename} would give you the individual object addresses which can be passed to !gcroot.

Curt Hagenlocher
Ilya Ryzhenkov
Use their type names. It's been a long time since I used these, but you should be able to use their type names to restrict the output from !dumpheap by using the -type option -- which also supports wild cards. If you're not sure what their type names are, use -stat to list all types.
Curt Hagenlocher
@Curt, CCWs are not represented as managed object. All RCWs has type of __ComObject.
Ilya Ryzhenkov
Ilya, not all RCW has __ComObject in the name. They may have a "normal" name, if some interop assembly is used (created by VS.Net when you reference the COM object).
Sunny