views:

44

answers:

1

I have an Windows C++ application which has a memory leak. I am pretty sure the leak is in one of our (many) linked libraries. I have instrumented the global new and delete function in our app and the app calls to allocate memory seem fine. They account for about 10% of the process working set though. When I walk the heaps // http://msdn.microsoft.com/en-us/library/ee175819%28v=VS.85%29.aspx returned by GetProcessHeaps() http://msdn.microsoft.com/en-us/library/aa366571%28v=VS.85%29.aspx

I can see about a dozen heaps, one of which has about a half gigabyte of allocations in it. Opps!

Ok so HOW can I find out which of the libs are doing it? Is there anyway to figure out who is allocating the heaps? I have the handle of each heap.

+1  A: 

The straightforward method would be to hook the HeapCreate() function. An example of doing that is here.

wallyk
Or just set a breakpoint on it.
Hans Passant
HeapCreate is a windows API that backs new() and malloc. So a straight breakpoint will not work I think. The Chrome code looks interesting but it is complex and I need to study it more. Thanks Wallyk
meissnersd