3

I am debugging a memory leak issue in a java application with some native code using jna, I am using the Valgrind, I found that the java application started by valgrind run very slowly, I know that application started by valgrind may slow down for 10-50 times than native code in the official documentation, but it is really time-consuming for debugging, in my case I only need to debug the jna native code, is possible to have valgrind ignore the jvm code(libjvm.so) and focus on my native library?

I have the following configuration.

  1. My jna native code is compiled with the gcc options -g and -O0
  2. valgrind is invoked with the parameters valgrind --leak-check=yes --error-limit=no --suppressions=/root/valgrind_errors.txt java -jar xxx.jar
  3. also I tried to recompile JRE with the gcc options -g and -O0, it didn't speed up the execution.

Do you have some suggestions to speed up the execution?

Thanks.

Jinlxz Liu
  • 421
  • 3
  • 12
  • 2
    I think this is an excellent question. I fear, however, that the answer will be "hard luck". The JVM allocates memory ferociously, and all that allocation and dellocation needs to be tracked by Valgrind. I'd love to find that there is a way to speed it up, but I'm not hopeful. – Kevin Boone Sep 29 '20 at 13:09
  • Since most of the JVM functionality is actually in a shared object (`libjvm.so`, IIRC), this may be useful: [**Is it possible to make valgrind ignore certain libraries?**](https://stackoverflow.com/questions/3174468/is-it-possible-to-make-valgrind-ignore-certain-libraries) – Andrew Henle Oct 04 '20 at 13:05

1 Answers1

0

You can find some indications on how to tune valgrind in https://archive.fosdem.org/2015/schedule/event/valgrind_tuning/

A.o., you could use --undef-value-errors=no

phd
  • 3,669
  • 1
  • 11
  • 12