Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: Make Perl use real malloc

by creamygoodness (Curate)
on Mar 15, 2011 at 18:56 UTC ( #893402=note: print w/replies, xml ) Need Help??


in reply to Re^3: Make Perl use real malloc
in thread Make Perl use real malloc

I believe that in those examples, Perl is actually leaking the scalars, along with a lot of other stuff -- look at the "still reachable" stat. It's doing this intentionally, by exiting immediately rather than painstakingly deallocating everything first.

In order to persuade Perl to deallocate everything, you need a Perl compiled with -DDEBUGGING and to set the PERL_DESTRUCT_LEVEL environment variable to 2. You are also likely need to create a Valgrind suppressions file to adapt for miscellaneous noise from libc, Dynaloader, etc.

In the end, though, you still don't see any difference when running those two examples. I would argue that the proof needed tightening up -- but the reasoning and explanation were sound.
marvin@smokey:~ $ PERL_DESTRUCT_LEVEL=2 valgrind --show-reachable=yes +--leak-check=full \ > --suppressions=~/debugperl.supp \ > debugperl -e'my $x; $x = \$x; undef $x if $ARGV[0]' 1 ==79872== Memcheck, a memory error detector ==79872== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et +al. ==79872== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright + info ==79872== Command: debugperl -emy\ $x;\ $x\ =\ \\$x;\ undef\ $x\ if\ $ +ARGV[0] 1 ==79872== --79872-- /Users/marvin/bin/debugperl: --79872-- dSYM directory has wrong UUID; consider using --dsymutil=yes ==79872== ==79872== HEAP SUMMARY: ==79872== in use at exit: 94,131 bytes in 12 blocks ==79872== total heap usage: 625 allocs, 613 frees, 219,612 bytes all +ocated ==79872== ==79872== LEAK SUMMARY: ==79872== definitely lost: 0 bytes in 0 blocks ==79872== indirectly lost: 0 bytes in 0 blocks ==79872== possibly lost: 0 bytes in 0 blocks ==79872== still reachable: 0 bytes in 0 blocks ==79872== suppressed: 94,131 bytes in 12 blocks ==79872== ==79872== For counts of detected and suppressed errors, rerun with: -v ==79872== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from +0) marvin@smokey:~ $ PERL_DESTRUCT_LEVEL=2 valgrind --show-reachable=yes +--leak-check=full \ > --suppressions=~/debugperl.supp \ > debugperl -e'my $x; $x = \$x; undef $x if $ARGV[0]' 0 ==79881== Memcheck, a memory error detector ==79881== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et +al. ==79881== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright + info ==79881== Command: debugperl -emy\ $x;\ $x\ =\ \\$x;\ undef\ $x\ if\ $ +ARGV[0] 0 ==79881== --79881-- /Users/marvin/bin/debugperl: --79881-- dSYM directory has wrong UUID; consider using --dsymutil=yes ==79881== ==79881== HEAP SUMMARY: ==79881== in use at exit: 94,131 bytes in 12 blocks ==79881== total heap usage: 625 allocs, 613 frees, 219,612 bytes all +ocated ==79881== ==79881== LEAK SUMMARY: ==79881== definitely lost: 0 bytes in 0 blocks ==79881== indirectly lost: 0 bytes in 0 blocks ==79881== possibly lost: 0 bytes in 0 blocks ==79881== still reachable: 0 bytes in 0 blocks ==79881== suppressed: 94,131 bytes in 12 blocks ==79881== ==79881== For counts of detected and suppressed errors, rerun with: -v ==79881== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from +0) marvin@smokey:~ $

Replies are listed 'Best First'.
Re^5: Make Perl use real malloc
by ikegami (Patriarch) on Mar 15, 2011 at 19:11 UTC

    I believe that in those examples, Perl is actually leaking the scalars, along with a lot of other stuff -- look at the "still reachable" stat. It's doing this intentionally, by exiting immediately rather than painstakingly deallocating everything first.

    The lesson to take was that there is no difference in the valgrind output between the two runs, which demonstrates that it can't detect the scalars that I leaked in the second run.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://893402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2023-04-01 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?