Valgrind 和 Java
我想使用 Valgrind 3.7.0 来查找 Java 本机代码中的内存泄漏。我使用的是jdk1.6.0._29。
为此,我必须设置 --trace-children=yes 标志。设置该标志后,我不再可以在任何 java 应用程序上运行 valgrind,即使是这样的命令:
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,但没有用。
在没有 Valgrind 或没有 --trace-children 标志的情况下运行程序就可以了。
有人知道我能做什么吗?
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 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
will get the error message:
Error occurred during initialization of VM
Unknown x64 processor: SSE2 not supported
I've seen this link: https://bugs.kde.org/show_bug.cgi?id=249943, but it was not useful.
Running the program without Valgrind or without the --trace-children flag is fine.
Does anyone has any idea on what I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须禁用 JIT 才能在 valgrind 下运行 JVM,如下所示:
另外,如果您最终使用生成的抑制(而且您很可能会!),则生成的抑制中的调用堆栈深度可能存在问题,这会导致在JVM下运行时更有可能发生。
在 valgrind 的最新版本中,生成的抑制可以包含比 valgrind/memcheck 本身可以处理的更深的调用堆栈。此问题的症状是 valgrind 意外终止,并显示消息“堆栈跟踪中调用者过多”。
这个问题很容易解决:在构建 valgrind 之前,编辑文件 coregrind/m_errormgr.c 并将 #define 中的硬编码值更改为更大的值(我使用 99):
然后按照文档构建并安装 valgrind。
You must disable JIT to run the JVM under valgrind, like so:
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):
Then build and install valgrind as per the docs.
Valgrind 捕获并模拟(在一定程度上)处理器,这似乎导致 JVM 对您对 SSE 的支持感到困惑并摆脱困境,
我建议您尝试告诉 JVM 不要打扰 SSE,您应该能够将其关闭使用 JVM 标志
-XX:UseSSE=0
关闭热点祝你好运! valgrind JVM 有点难,因为它们彼此有些敌意
这也可能是你的 valgrind 和 java 版本我在本地运行你的命令,没有任何问题,使用 valgrind 3.6.1 以及 java 1.6.0_26 和 java 1.7.0-b147
Valgrind traps and emulates (to a degree) the processor, this is seemingly causing the JVM to get confused about your support for SSE and bailing out
I would suggest your try telling the JVM not to bother with SSE, you should be able to turn this off for hotspot with the JVM flag
-XX:UseSSE=0
Good luck! valgrinding the JVM is a bit hard as they are somewhat hostile to each other
It might also be your version of valgrind and java I ran your command from above locally and had no problems, using valgrind 3.6.1 and both java 1.6.0_26 and java 1.7.0-b147