It works the same way. The killer is freeing up all the bucket entries, and when you undef the hash they get freed just the same as when the hash goes out of scope. There's rather a lot of small memory malloc'ing going on (with corresponding extra overhead in memory footprint that's generally unaccounted for) and when those get freed it triggers some pathological behaviour in some versions of glibc's memory system.