Are you sure about that? I recall that there is only one copy of the undef value in memory, and I'm not sure that perl fills all the buckets from 0 to 9999 when you set 10000. Why don't you try just setting 10000 and see how much memory the program takes? If it's not much, you can just forget all about this.