Hi Monks,
I have some script which uses some mildly complex data structures and consumes a lot of memory. I wanted to do some memory usage profiling and came across Devel::DumpSizes.
Since the results seemed very strange, I tried to see what &Devel::Size::size (which is the basic function it uses) gives for simple scalars.
The way I understand it, for scalars the results should be the same as length() returns. Why isn't it so?
I started off with bit-vector style values but also a simple example such as the last one, the variable $five, demonstrates it as well. Acording to Devel::Size it coonsumes 37 bytes (?!) what do I miss here?
#!/usr/bin/perl -w use Devel::Size qw(size total_size); my $packed1=pack("b24",'111100001111000011110000'); my $packed2=pack("b24",'111100000000000011110000'); my $raw='111100001111000011110000'; my $xor=($packed1^$packed2); my $five=5; printf "packed1 %d, %d\n",length($packed1),size($packed1); printf "packed2 %d, %d\n",length($packed2),size($packed2); printf "raw %d, %d\n",length($raw),size($raw); printf "xor %d, %d\n",length($xor),size($xor); printf "five %d, %d\n",length($five),size($five);

In reply to Help needed on Devel::Size by tcarmeli

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.