I've compiled ruby (2.2.4
) with debugflags='-g' optflags='-O0' ./configure --with-valgrind
as suggested by the valgrind-docs. According to at least several though obscure resources people have used Valgrind with ruby successfully, more so the --with-valgrind
option appears to exist as of 1.9.3
./doc/ChangeLog-1.9.3:62800: * configure.in: add --with-valgrind.
The error I have is identical to the one referred to in the analogous python question, where even a basic test program reports numerous false positives for 'reference lost' / 'probably lost'.
sample output:
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)
.....