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?
-
What is your compiler and OS?Steve Townsend– Steve Townsend2011-06-20 12:59:09 +00:00Commented Jun 20, 2011 at 12:59
-
Windows Server 2003. C++ code is visual studio programs.Kannan J– Kannan J2011-06-21 09:48:55 +00:00Commented Jun 21, 2011 at 9:48
-
Are you asking about memory leaks in your C++ code in general, or JNI objects in the heap specifically?Eric– Eric2011-06-21 14:07:40 +00:00Commented Jun 21, 2011 at 14:07
-
My C++ code is called only from a JVM via JNI calls. So I'm asking about JNI objects in the heap specifically.Kannan J– Kannan J2011-06-23 05:23:16 +00:00Commented Jun 23, 2011 at 5:23
Add a comment
|
2 Answers
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.
2 Comments
Kannan J
Can you tell how I use it for JNI application? Run the tool on java.exe itself?
Steve Townsend
My understanding is that the C++ code you call will run in the same process within
java.exe, in which case its heap usage can be tracked this way. if you are lucky the JVM will use a different native heap in which to manage GC memory, making identifying C++ usage straightforward.