in reply to Bug when undefining a large hash

Maybe you could try a two-step approach:

%hash = (); undef %hash;
to see if it improves the situation.

update

May you can also try delete. It is supposed to be slower but it would be interesting to compare. I have tried your example on Windows XP and Redhat (both Perl 5.8) and it runs fine. Strangely enough it takes a bit longer under Redhat?! Unfortunately I don't have FreeBSD available.

Replies are listed 'Best First'.
Re^2: Bug when undefining a large hash
by oxone (Friar) on Aug 22, 2008 at 13:46 UTC

    Thanks for suggestions! Results:

    "%hash = ();" appears to do much the same as undef(), at least, it creates the same long delay.

    Iterating all the keys and deleting them is slower than undef, although not by much: around 16 secs as opposed to 14 secs for undef.

    So, no solutions there, but thanks for the ideas.

      Frankly speaking that didn't surprise me. I just thought it was worth a try. I tried it myself on Redhat also with increased values up to 30_000_000 same results as you.