in reply to Does undef free ram?
Yes, undef is the best way to completely release the memory that an array uses. That memory will be available for reallocation in your program. The memory will not, unless the array is very large and you're using an OS or version of libc that supports it, be released back to system.
In this case, where your array is 10K elements or so, it's probably not worth it. That's only using 40K of memory, which really isn't that much.