in reply to hashref population yields out of memory error

What's odd is that I rewrote Data::Bucket to use MLDBM but memory is still being exhausted:
sub bucket_hash { my ($self) = @_; if ($self->{on_disk}) { defined $self->{dir} and $self->{dir} = "$self->{dir}/" ; my $outfile = sprintf "%s%s", $self->{dir} , ($self->{file} || "deep.db") ; my %o; my $dbm = tie %o, 'MLDBM', 'testmldbm', O_CREAT|O_RDWR, 0640 or +die $!; $self->{bucket} = \%o; } for my $data (@{$self->{data}}) { my $index = $self->compute_record_index($data); my @index = ref $index eq 'ARRAY' ? @$index : ($index) ; for (@index) { my $tmp; if (exists $self->{bucket}{$_}) { $tmp = $self->{bucket}{$_} ; } else { $tmp = []; } push @$tmp, $data; $self->{bucket}{$_} = $tmp; # push @{ $self->{bucket}{$_} }, $data ; } } return $self; }
I have beheld the tarball of 22.1 on ftp.gnu.org with my own eyes. How can you say that there is no God in the Church of Emacs? -- David Kastrup
[tag://cpan-bucket-hash,memory,sqlite]
Enforce strict model-view separation in template engines via HTML::Seamstress The car is in the cdr, not the cdr in the car

Replies are listed 'Best First'.
Re^2: hashref population yields out of memory error
by metaperl (Curate) on Dec 28, 2007 at 20:18 UTC