Valgrind和Java [英] Valgrind and Java
问题描述
我想使用Valgrind 3.7.0在我的Java本机代码中查找内存泄漏。我正在使用jdk1.6.0._29。
I want to use Valgrind 3.7.0 to find memory leaks in my Java native code. I'm using jdk1.6.0._29.
为此,我必须设置--trace-children = yes标志。设置该标志,我不再可以在任何java应用程序上运行valgrind,甚至可以执行以下命令:
To do that, I have to set the --trace-children=yes flag. Setting that flag, I no longer can run valgrind on any java application, even a command like:
valgrind --trace-children=yes --smc-check=all java -version
将收到错误消息:
Error occurred during initialization of VM
Unknown x64 processor: SSE2 not supported
我看过这个链接: https://bugs.kde.org/show_bug.cgi?id=249943 ,但没用。
I've seen this link: https://bugs.kde.org/show_bug.cgi?id=249943, but it was not useful.
运行程序没有Valgrind或没有--trace-children标志是好的。
Running the program without Valgrind or without the --trace-children flag is fine.
有没有人知道我能做什么?
Does anyone has any idea on what I can do?
推荐答案
您必须禁用JIT才能在valgrind下运行JVM,如下所示:
You must disable JIT to run the JVM under valgrind, like so:
valgrind java -Djava.compiler=NONE ...
此外,如果您最终使用生成抑制(和你可能会!),生成的抑制中调用堆栈的深度可能存在问题,在JVM下运行时更有可能发生。
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.
在valgrind的最新版本中,生成的抑制可以包含比valgrind / memcheck本身可以处理的更深的调用堆栈。这个问题的症状是valgrind意外终止,消息堆栈跟踪中的调用者太多。
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".
这个问题很容易解决:在构建valgrind之前,编辑文件coregrind / m_errormgr.c并将#define中的硬编码值更改为更大的值(我使用99):
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
然后根据文档构建并安装valgrind。
Then build and install valgrind as per the docs.
这篇关于Valgrind和Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!