Hi Yossi,
On Thu, 22 May 2014 06:27:47 +0000
Yossi Itzkovich <[email protected]> wrote:
> Hi,
>
> Here is a small test that shows the problem (memory consumption of counting
> the size of a huge hash, with not-so-small keys)
>
> -------
> my %hash;
> for (my $i=0; $i<5000000;$i++){
> $hash{$i x 100}=$i};
> print "OK\n";
> sleep 20; ### Here the memory is about 3G
> print (scalar keys %hash,"\n");
> sleep 10 ### here the memory is 3.5 G
> ------
>
With this program:
«
#!/usr/bin/perl
use strict;
use warnings;
my %hash;
for (my $i=0; $i<2000000;$i++)
{
$hash{$i x 100}=$i;
};
print "OK\n";
my $l = <>;
print (scalar keys %hash,"\n");
print "Type enter to exit.\n";
$l = <>;
»
I don't see a noticeable increase in memory between the two stages. The memory
stays mostly the same at the time, according to htop. I tried with both
perl-5.18.2-4.mga5 and bleadperl on Mageia Linux x86-64 v5. What is your perl
version, the OS+distribution you are using, etc.?
Regards,
Shlomi Fish
> Well, it means the list is being built, and it does consume a lot of memory
> (and CPU- but this is not my problem here). In my real application it
> crashes, since I have bigger hash/keys, and I am getting "out of memory"
> crash.
>
> Isn't there a better way to get the hash size ?
>
> Yossi
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Beginners Site for the Vim text editor - http://vim.begin-site.org/
When Chuck Norris disses your product, it’s not good publicity, even though
you can bet he’ll get the name right.
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/
Please reply to list if it's a mailing list post - http://shlom.in/reply .
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl