Search code examples
.netwindbgsosunmanaged-memory

memory area used by unmanaged componet for allocations/deallocations


Let's say a .net managed application interfacts with an unmanaged component via InterOP. If I have to debug a memory issue; where exactly unmanaged component allocates memory? Is it the same heap that is used by GC (which I doubt) or is it some other areas? I am doing Windbg debugging and wondering if I can look at allocation by unmanaged component via SoS commands like !dumpheap?


Solution

  • In Windbg you can use !heap to inspect native heap memory. The GC (managed) heap is disjoint from native code heap usage, though at some level my assumption is that the managed heap must be mapped (inside the CLR) onto one or more native heaps.

    SoS is purely used for managed code debugging - WinDbg is first and foremost a native code debugging tool.

    umdh.exe may also be useful, though I've not tried this in a mixed-mode app.