Cristoforo has asked for the wisdom of the Perl Monks concerning the following question:
When asking for the size of a newly created hash, it gave me one size. But after accessing the hash, it gave a size almost 50% larger.
The results of running this code was:#!/usr/bin/perl use strict; use warnings; use Devel::Size 'total_size'; my $s = 'AAAAAAAAAAAAAAA'; my %hash = map {$s++ => 1} 1 .. 1000; print total_size(\%hash). ' ' . keys(%hash) . "\n"; open my $fh, '>', 'j1.txt' or die $!; for my $key (keys %hash) { print $fh "$key $hash{$key}\n"; } print total_size(\%hash). ' ' . keys(%hash) . "\n";
105248 1000 145288 1000
I'm using perl version 5.014 and the version of Devel::Size is .08.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Devel::Size reports different size after hash access
by BrowserUk (Patriarch) on Oct 25, 2016 at 20:25 UTC | |
|
Re: Devel::Size reports different size after hash access
by GrandFather (Saint) on Oct 25, 2016 at 20:20 UTC | |
|
Re: Devel::Size reports different size after hash access
by stevieb (Canon) on Oct 25, 2016 at 20:19 UTC | |
by GrandFather (Saint) on Oct 25, 2016 at 20:22 UTC | |
by Cristoforo (Curate) on Oct 26, 2016 at 01:02 UTC | |
|
Re: Devel::Size reports different size after hash access
by Cristoforo (Curate) on Oct 25, 2016 at 22:05 UTC |