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?