Tech Off Post

Single Post Permalink

View Thread: Finding memory leaks in native code when P/Invoking
  • User profile image
    Ion Todirel

    WinDbg, call your API in a tight loop and confirm it is responsible for the leak, better yet call your native API from native, you could have your leak at the marshalling layer. If the memory footprint increments linearly, find the source of the leak. You can look at the heaps and then identify the objects taking the most of it, see the documentation for !heap. Alternatively, a classic technique is to track allocations by overriding new/delete. Don't know of any other ways to do it. There's tool that can automate some of this, Visual Studio has one too I believe, but that's just uncool in my book. Use WinDbg.

    BTW, if you have leaks in native code you used C++ very inappropriately Cool