Вопрос

I'm trying to find a memory leak in one of our applications, however it's quite elusive.

I've analyzed the program with Ants memory profiler and it found the leak to be in unmanaged code, for which Ants memory profiler is not suited: http://www.red-gate.com/supportcenter/content/ANTS_Memory_Profiler/help/7.4/amp_unmanaged_use I checked the things in the "graphics buffers" and "Problems with object disposal in unmanaged code" section, but that didn't give any results.

I then used the Windows debug diagnostic tool and did a memory pressure analysis. Majority of memory usage is in in the native heaps: heap 6 0x01ee0000 (not the default process heap). Virtual allocation summary memory is low and outstanding allocation summary memory in the leak analysis is low: none of the modules have high memory usage.

How do I find where the memory leak is located now?

Это было полезно?

Решение

Memory leak diagnostics is a built-in feature of the Microsoft CRT, the _CrtDumpMemoryLeaks() function provides a report. Using it requires writing unit tests in native code so that you can enable the debug allocator to make this function work. Which in turn requires that you have to source code for this unmanaged code so you can enable the debug allocator with the <crtdbg.h> header file and can build the unit test. Essential guide is here.

The usual sticking point is that you don't have access to the native source code. In which case you'll need to work with the vendor or author of this code to get this problem sorted out. Get the ball rolling by providing him with a small repro project that demonstrates the problem.

Другие советы

If you want a real memory profiler tool, have a look at http://memprofiler.com/support.aspx. By far one of the best tools for memory leaks that I have ever used. .NET interops with unmanaged code all over the place. Just because the leak appears in unmanaged code doesn't mean that you don't have a held-reference issue in your code somewhere. If you provide some details of why you think you have a memory leak issue and more about your solution perhaps we can offer more solutions.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top