That's due to the memory policies of Perl. You undef a large
hash, which means that for each value stored, Perl has to
decrement the refcount of the value, check to see if it's
zero, and if it's zero, free its memory (and possibly decrement other ref counters). Finally, it needs to free up
the memory structure of the hash itself, which will be lots
of linked lists, so there are lots of little pieces of memory
to be freed.