2

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?

4
  • What is your compiler and OS? Commented Jun 20, 2011 at 12:59
  • Windows Server 2003. C++ code is visual studio programs. Commented 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? Commented 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. Commented Jun 23, 2011 at 5:23

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you tell how I use it for JNI application? Run the tool on java.exe itself?
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.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.