Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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:~ $

In reply to Re^4: Make Perl use real malloc by creamygoodness
in thread Make Perl use real malloc by creamygoodness

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-16 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found