Storable excessive memory usage?

Before I submit a bug report , has anyone observed the memory usage pattern of Storable?

What Happens?

First I create a hash with 30 megs of memory:

my $s   = 'x' x 1000000;
my %res = map { $_ => $s } 1..30;

having afterwards a process (virtual) size of ~50 MB.

Then I use Storable to freeze that:

use Storable qw(freeze);
warn "size: ".length (freeze (\%res));

Even though I immediately throw away the ice block, I would find it ok if the process size is around 80. But it is actually 107 MB.

How so?

Environment

This happens with

  • v5.10.0 built for darwin-thread-multi-2level, and
  • v5.10.0 built for i486-linux-gnu-thread-multi
  • Storable 2.20

What Escape Manoeuvre?

What are my options? This does not happen if I use, say Data::Dumper. But it also happens when I use JSON, for instance.

Posted In