in reply to Profiling the C side of an Inline::C module

I was wondering if using valgrind would work. So, i tried it with a very simple c program:
#include <stdlib.h> int main(){ int *p = malloc(sizeof(int)); free(p); return 0; }
and returned:

ERROR SUMMARY:
0 errors from 0 contexts (suppressed: 17 from 2)
malloc/free: in use at exit: 0 bytes in 0 blocks.
malloc/free: 1 allocs, 1 frees, 4 bytes allocated.

Everything is ok. Now, i try it using:
/usr/local/bin/valgrind perl -e 'print "Hello, world!\n";'
and i get:

LEAK SUMMARY:
definitely lost: 222050 bytes in 655 blocks.
possibly lost: 0 bytes in 0 blocks.
still reachable: 0 bytes in 0 blocks.
suppressed: 0 bytes in 0 blocks.
Use --leak-check=full to see details of leaked memory.

Wow. Trying to profile some mixed code, like:
print "Hi, C!\n"; use Inline C; waste(); __END__ __C__ void waste(){ void *p = malloc(sizeof(int)); //free(p); printf("Hi, Perl!\n"); }
becomes a hell!

Has anybody tried succesfully valgrind on perl?

Replies are listed 'Best First'.
Re^2: Profiling the C side of an Inline::C module
by samtregar (Abbot) on Sep 04, 2005 at 23:41 UTC
    I've seen summaries on perl5-porters of valgrind runs on Perl itself. I don't think I've seen anything about running valgrind on an XS module, but it might be worth exploring.

    -sam