Forum Discussion

taco_indenbosch's avatar
14 years ago

Undetected memory leaks

Dear reader,

I have an application that I am currently testing for memory leaks. It is a project that consists of a managed portion in C# (the executable and several DLLs) and a mixed managed/unmanaged DLL in C++/CLI. This DLL links an unmanaged static link library in C++.

I have found several leaks, some concerning C++ objects through new and delete, and some system allocations through VirtualAlloc and VirtualFree. So I know both allocation types are properly detected by AQtime.

Currently no more leaks are detected, so I would expect the application to be leak free. However, when I run the application in a loop the amount of memory in use as reported by the task manager for the process keeps increasing, from the initial 20MB or so up to 150 MB and more, depending on how long I let the application continue.

I execute the main functionality hundreds of times, resulting in a run time of several minutes, so I am pretty sure that lingering objects are garbage collected. In addition I have tried to force a garbage collection for each iteration. This does not make a difference.

When I get the results at various points in time and look at the classes data - live count then I do not see the numbers growing when I am running a debug version. They do increase for certain classes when I run the release version. Both versions see their used memory increasing in the task manager, however.

I am still relatively confident that I am not keeping live references to a growing pool of objects, which could account for the memory usage increasing without memory leaks on program termination, since the remembered objects would then ultimately be reclaimed. But the information in the paragraph above prevents me from being sure about that.

I have no idea what is going on here. If someone else can give me a pointer then that would be greatly appreciated.


1 Reply

  • Hello Taco,

    Probably, the application is leaking native memory. Try enabling the "Check system memory allocations" option of the Allocation Profiler.

    Also, when viewing the results, disable the "View Project Classes Only" option in the report panel's toolbar.

    I hope this helps.