Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 (Pope) 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
Node Status?
node history
Node Type: note [id://893402]
help
Chatterbox?
[1nickt]: Ah, you got Linus' fave? With Ubuntu? 4k display?
[1nickt]: ( The 17" monster I just bought is for my wife, who doesn;t leave the house with it...)
[Corion]: 1nickt: No, I'm using it with Windows 10, but with the 4k display, yes. It's a very nice build IMO, and relatively sturdy. Also, it got 8 or 9 on the ifixit repair scale, which I consider good
[Corion]: ... especially as I expect to have to replace the battery set in two or three years' time
[1nickt]: Nice. So happy that Dells are still user-repairable. Unusual these days.
[1nickt]: I will certainly not be buying any more Macs.
[Corion]: 1nickt: Yeah, or at least, I hopoe so ;)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2017-03-27 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.