On Thu, May 27, 2004 at 07:12:58AM +0200, Tassilo von Parseval wrote: > For XS modules, I'd always use valgrind (http://valgrind.kde.org/):
Ok. I thought there might be a Perl module to check for leaks. But valgrind is cool. So, this shows leaks -- are those my errors or are they in Perl? I'm guessing Perl because: valgrind --leak-check=yes perl -le "$x = 1" shows lost memory. But, I'm not so sure -- if I comment out my "safefree()" call in my .xs code the report changes only slightly. Maybe it's better to wrap my tests in while(1) loop and just see if the process size keeps growing! Here's running my test script for my module (with the safefree() call enabled). [EMAIL PROTECTED]:~/swish-e/perl$ valgrind --leak-check=yes perl -Iblib/lib -Iblib/arch t/test.t ==17816== Memcheck, a memory error detector for x86-linux. ==17816== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward. ==17816== Using valgrind-2.1.1, a program supervision framework for x86-linux. ==17816== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward. ==17816== For more details, rerun with: -v ==17816== 1..145 ok 1 Call SWISH::API::new [...] ==17816== warning: Valgrind's siglongjmp is incomplete ==17816== (it ignores cleanup handlers) ==17816== your program may misbehave as a result ==17816== ==17816== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 26 from 2) ==17816== malloc/free: in use at exit: 635283 bytes in 9153 blocks. ==17816== malloc/free: 21118 allocs, 11965 frees, 18973223 bytes allocated. ==17816== For counts of detected errors, rerun with: -v ==17816== searching for pointers to 9153 not-freed blocks. ==17816== checked 3813540 bytes. ==17816== ==17816== 5 bytes in 1 blocks are definitely lost in loss record 1 of 19 ==17816== at 0x3C01F40D: malloc (vg_replace_malloc.c:105) ==17816== by 0x80AAF25: Perl_savesharedpv (in /usr/bin/perl) ==17816== by 0x8065994: (within /usr/bin/perl) ==17816== by 0x80623C4: (within /usr/bin/perl) ==17816== ==17816== ==17816== 200 bytes in 1 blocks are definitely lost in loss record 11 of 19 ==17816== at 0x3C01F40D: malloc (vg_replace_malloc.c:105) ==17816== by 0x3C05EF89: my_malloc (vg_libpthread.c:334) ==17816== by 0x3C0621F0: get_or_allocate_specifics_ptr (vg_libpthread.c:1591) ==17816== by 0x3C0623A4: pthread_key_create (vg_libpthread.c:1628) ==17816== ==17816== ==17816== 1707 bytes in 13 blocks are definitely lost in loss record 13 of 19 ==17816== at 0x3C01F40D: malloc (vg_replace_malloc.c:105) ==17816== by 0x80A9FAE: Perl_safesysmalloc (in /usr/bin/perl) ==17816== by 0x8066C64: Perl_init_stacks (in /usr/bin/perl) ==17816== by 0x8060899: perl_construct (in /usr/bin/perl) ==17816== ==17816== ==17816== 6352 bytes in 2 blocks are definitely lost in loss record 15 of 19 ==17816== at 0x3C01FD01: realloc (vg_replace_malloc.c:162) ==17816== by 0x80AA07F: Perl_safesysrealloc (in /usr/bin/perl) ==17816== by 0x80E6059: Perl_savestack_grow (in /usr/bin/perl) ==17816== by 0x80E6B27: Perl_save_I32 (in /usr/bin/perl) ==17816== ==17816== ==17816== 143700 bytes in 13 blocks are possibly lost in loss record 18 of 19 ==17816== at 0x3C01F40D: malloc (vg_replace_malloc.c:105) ==17816== by 0x80A9FAE: Perl_safesysmalloc (in /usr/bin/perl) ==17816== by 0x80B4D66: Perl_reentrant_init (in /usr/bin/perl) ==17816== by 0x8060AB4: perl_construct (in /usr/bin/perl) ==17816== ==17816== LEAK SUMMARY: ==17816== definitely lost: 8264 bytes in 17 blocks. ==17816== possibly lost: 143700 bytes in 13 blocks. ==17816== still reachable: 483319 bytes in 9123 blocks. ==17816== suppressed: 0 bytes in 0 blocks. ==17816== Reachable blocks (those to which a pointer was found) are not shown. ==17816== To see them, rerun with: --show-reachable=yes I sure can kill a lot of free time doing this stuff.... -- Bill Moseley [EMAIL PROTECTED]