Running a JNI application in a Sun virtual machine under Valgrind

The JVM sun makes a lot of noise when working under valgrind, which makes the task of tracking memory in the application difficult.

I would like to find a suppression file or VM runtime that will suppress false memory errors in order to separate the wheat from the chaff in this situation. Any suggestions?

+5
java valgrind jni
source share
3 answers

How about profiling this native code outside of a Java application? Typically, JNI code is a wrapper around some library that is not specific to Java. Not sure if this is true for your particular case, but if it is possible memory problems can be isolated by writing a normal C or C ++ test environment around this library?

If your framework is in C ++, you can also provide your new ones and delete statements and monitor memory usage. You will have to collect statistics and process them using some scripts, but it may work well.

+1
source share

I can’t answer your question, but can you clarify what your problem is?

In other words, can you tell us if this ...

  • In the JNI layer, and not in the scope of the JVM object?
  • Using free memory?
  • Sign / overwrite buffer?
  • Other memory corruption?

I recently had to debug Java / C, which had problems (after 30+ minutes in its launch), which, as it turned out, used memory after it was free. I tried using dmalloc, my own memory leak library, Valgrind, and no one worked as I needed.

In the end, I created a simple set of wrappers around free, malloc, calloc, realloc, which simply printed addresses and memory sizes into a file. After it was interrupted (inside GDB), I could return on time and find out when the memory was free and where the links were not deleted.

IF your problem is in C / C ++ and you can catch a bug in the debugger, this may work for you. Yes, this is tedious, but perhaps no worse than sifting through a megabyte of Valgrind output.

Hope this helps and good luck.

+1
source share

Although not as strong as valgrind (based on what I read), you can try jmap and jhat. These tools allow you to take a snapshot of the current process and see what happens. I used this method for simple memory leaks and it worked well. However, if memory problems are caused by non-jvm allocations, this will not help.

0
source share

All Articles