Working on one project I stay before problem of memory requirements. Tried to use tied hashes I doscover taht my code eat more and more of my memory. Each iteration through all data in that hash cost me other memory space. After some experiments I've got following code which demonstrate this behaviour. It looks like problem with Storable.

What goes on? Where is my memory?

#!/usr/bin/perl -w use strict; use Set::Scalar; use Storable qw(nfreeze thaw); my $iterations = 20; my $set_count = 100; my $data = 'abcdefgh'; srand(); for (my $cycle = 0; $cycle < $iterations; $cycle ++) { { my $tmp = $data; my $r_arr; $tmp .= chr(int(rand(26))+65); for (my $set = 0; $set < $set_count; $set ++) { my $scalar_set = Set::Scalar->new(split(//, $tmp)); push @$r_arr, thaw( nfreeze( $scalar_set ) ); } } &procinfo; } exit 0; sub procinfo { my @stat; open( STAT , '<', "/proc/$$/stat" ) or die "Unable to open stat file +"; @stat = split /\s+/ , <STAT>; close( STAT ); printf "Vsize: %3.2f MB\t", $stat[22]/1048576; print "RSS : $stat[23] pages\n"; }

In reply to Storable: where is my memory? by ph0enix

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.