in reply to wait till memory is flushed

I am curious, how do you "check my memory"?

I want this memory to be removed first Why? Perl, like most systems, will reuse allocated memory if it can - that is more efficient than freeing it and then allocating again. Very few systems allow an application to return memory to the OS anyway. It is, after all, probably virtual memory (although you don't say which operating system you are using), so it will not be locked in RAM.

If you are really worried about this then run the hash processing in another process, the memory will be freed and returned to the OS when that process ends. You can save the hash using something like Storable.