in reply to hash on memory or disk?

Thanks for all your quick replies. I'll give them a try and let you know what happens.

JS.

Replies are listed 'Best First'.
Re: Re: hash on memory or disk?
by js1 (Monk) on Jan 14, 2004 at 11:24 UTC

    Does this test for an empty hash use a lot of memory if the hash is big?
    $nmail->relay('<>',1) unless keys %$hash_ref;

      No, keys in scalar context just returns the number of elements of the hash; and the hash keeps score in its internal datastructure.

      This is of course assuming we are talking about a normal hash. If the hash is tied, then it will depend on the implementation.

      Abigail

        Thanks for your reply.

        I have managed to reduce some of the memory usage (because I'm able to process more of the log now) but my program is still crashing. I'm having a problem tying the hashes whose elements are arrays e.g.

        tie %recipientqids, 'MLDBM', "/home/u752359/recipientqids.db", O_CREAT +|O_RDWR, 0640 or die $!; push(@{$recipientqids{$hostqid}},$recipient); .. .. foreach $hostqid( @{$msgidqids{$msgid}}){ foreach $recipient (@{$recipientqids{$hostqid}}){ print STDERR "\nrecip= $recipient"; } }

        doesn't print anything if I tie the recipientqids hash.

        Is my syntax wrong, or can you not store these structures with MLDBM?

        Thanks,

        js1