in reply to How do I pre-allocate an array of hashes?

The short answer is you can't. There's nothing you can do at the user level to alter the way perl allocates memory for the base hash structures, and so you're stuck with the performance characteristics as long as you use the busted version of glibc.

The alternatives are either rebuild perl with perl's own malloc rather than the system one (as it doesn't have these issues) or find another malloc to link against rather than the one in glibc. (Which is somewhat problematic, but doable)

  • Comment on Re: How do I pre-allocate an array of hashes?

Replies are listed 'Best First'.
Re: Re: How do I pre-allocate an array of hashes?
by jaa (Friar) on Feb 24, 2003 at 11:09 UTC
    Thanks - other research bears this out too - will try rebuilding the debian stable Perl with -Dusemymalloc

    Incidentally, as an example, one script takes 14 minutes to decrypt, translate and save thousands of records into the database, and then sits around for 22 minutes freeing the large hashes before exiting.

    Jeff

      Yeah, this is due to the insane number of individual allocations that perl does when building hashes. It's something I'm looking into fixing for perl 6.