Valgrind and Java

后端 未结 2 682
花落未央
花落未央 2020-12-14 19:02

I want to use Valgrind 3.7.0 to find memory leaks in my Java native code. I\'m using jdk1.6.0._29.

To do that, I have to set the --trace-children=yes flag. Setting

2条回答
  •  一向
    一向 (楼主)
    2020-12-14 19:17

    You must disable JIT to run the JVM under valgrind, like so:

    valgrind java -Djava.compiler=NONE ...
    

    Also, if you end up using generated suppressions (and you most likely will!), there can be a problem with the depth of the call stacks in the generated suppressions, which is more likely to occur when running under the JVM.

    In recent versions of valgrind, generated suppressions can contain deeper call stacks than can be processed by valgrind/memcheck itself. The symptom of this problem is that valgrind terminates unexpectedly with the message "too many callers in stack trace".

    This problem is easily fixed: before building valgrind, edit the file coregrind/m_errormgr.c and change the hard-coded value in the #define to a larger value (I use 99):

     /* Max number of callers for context in a suppression. */
    
     #define VG_MAX_SUPP_CALLERS  99
    

    Then build and install valgrind as per the docs.

提交回复
热议问题