Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

chromatic
  (email not shown publicly)
http://wgz.org/chromatic/

Blog Information [technorati.com] Profile for chr0matic [technorati.com]

Journal of chromatic (983)

Sunday January 20, 2008
03:21 AM

49k Should Be Enough for Anyone

[ #35432 ]

My name is chromatic and I'm addicted to Valgrind. I fixed up "Hello, world!" in Parrot a few days ago so that it has no memory leaks and that felt good. Tonight I decided to see how the same program fares in Rakudo:

$ valgrind --suppressions=/home/chromatic/dev/parrot/tools/dev/parrot.supp --num-callers=500 --leak-check=full --leak-resolution=high --show-reachable=yes ../../parrot --leak-test perl6.pbc -e 'say "Hello, world!"'
LEAK SUMMARY:
    definitely lost: 28,206 bytes in 361 blocks.
    indirectly lost: 41,811 bytes in 218 blocks.
      possibly lost: 0 bytes in 0 blocks.
    still reachable: 20 bytes in 1 blocks.
         suppressed: 0 bytes in 0 blocks.

A lot of that came from the allocation of a new hash for each LexPad PMC. Hash memory (not Hash PMC memory) currently comes from malloc(), not GCable memory pools, so for each hash you create, you need to free it. I added a destroy() vtable entry to LexPad and set the active destroy flag in the initializer. Success!

$ vgp perl6.pbc -e 'say "Hello, world!"'
LEAK SUMMARY:
    definitely lost: 19,406 bytes in 161 blocks.
    indirectly lost: 211 bytes in 18 blocks.
      possibly lost: 0 bytes in 0 blocks.
    still reachable: 20 bytes in 1 blocks.
         suppressed: 0 bytes in 0 blocks.

There's still more work to do (though much of what remains is in the difficult-to-diagnose IMCC), but five new lines of code cut out a whole swath of problems. (Yes, vgp is a shell alias. I wouldn't type that by hand more than once.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.