我已根据valgrind-docs的建议,使用2.2.4
编译了ruby(debugflags='-g' optflags='-O0' ./configure --with-valgrind
)。根据至少有几个obscure resources人已成功使用Valgrind和ruby,因此--with-valgrind
选项似乎存在1.9.3
./ doc / ChangeLog-1.9.3:62800:* configure.in:add --with-valgrind。
我所遇到的错误与analogous python question中提到的错误完全相同,即使是基本的测试程序也会报告许多误报,因为参考丢失了#39; /'可能已经失去了'。
示例输出:
valgrind --tool=memcheck --leak-check=yes --max-stackframe=8382448 --track-origins=yes ruby test.rb
==15105== HEAP SUMMARY:
==15105== in use at exit: 840,786 bytes in 8,050 blocks
==15105== total heap usage: 10,496 allocs, 2,446 frees, 2,373,732 bytes allocated
==15105==
==15105== 16 bytes in 1 blocks are possibly lost in loss record 87 of 5,245
==15105== at 0x4C2ABD0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15105== by 0x1511F4: objspace_xmalloc0 (gc.c:7780)
==15105== by 0x1512CB: objspace_xmalloc (gc.c:7792)
==15105== by 0x15153F: ruby_xmalloc (gc.c:7871)
==15105== by 0x2E54CA: rb_class_subclass_add (class.c:41)
==15105== by 0x2E546F: RCLASS_SET_SUPER (internal.h:602)
==15105== by 0x2E58E8: rb_class_boot (class.c:205)
==15105== by 0x2E687B: boot_defclass (class.c:537)
==15105== by 0x2E6937: Init_class_hierarchy (class.c:554)
==15105== by 0x193EEE: InitVM_Object (object.c:3371)
==15105== by 0x1951C8: Init_Object (object.c:3596)
==15105== by 0x15C07F: rb_call_inits (inits.c:23)
.....