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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.