2
votes

My java application calls C++ code using JNI calls. I want to check the program for memory leaks in the C++ code. Tools like jconsole are only for analyzing java objects heap. What can I do?

2
What is your compiler and OS?Steve Townsend
Windows Server 2003. C++ code is visual studio programs.Hugh Darling
Are you asking about memory leaks in your C++ code in general, or JNI objects in the heap specifically?Eric
My C++ code is called only from a JVM via JNI calls. So I'm asking about JNI objects in the heap specifically.Hugh Darling

2 Answers

1
votes

My favourite native heap leak detection tool for Windows is umdh.exe. However, this will also display the current Java GC heap memory footprint, in whatever native form the JVM uses.

You should still be able to identify memory attributable to your C++ code since it will (provided symbols are set up properly according to the UMDH instructions) have a callstack matching C++ code. So having Java code coresident will muddy the waters but should not make it impossible to track C++/native memory usage.

0
votes

You need a native heap debugging tool. There are many available depending on your platform and what compiler was used for the native component.