Posted on 2013-12-06 10:26
Milo的海域 阅读(991)
评论(0) 编辑 收藏 所属分类:
Java 、
C
Java程序的memory leak分析也可以用valgrind, 尤其是JNI程序尤其有用:
valgrind --error-limit=no --trace-children=yes --smc-check=all --leak-check=full JAVA_CMD
特意写了个有leak的jni函数,用valgrind成功检查出来了
==31915== 100 bytes in 1 blocks are definitely lost in loss record 447 of 653
==31915== at 0x402CE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==31915== by 0x60424F9: Java_MyJNI_hello (MyJNI.c:16)
在老版本valgrind(3.5.0) enable了--trace-children选项后可能出现错误:
Error occurred during initialization of VM
Unknown x64 processor: SSE2 not supported
升级到最新版可以解决这个问题,升级方法:下载src包 解压后执行 ./configure; make; make install