in reply to Re: Garbage Collection and undef
in thread Garbage Collection and undef
I think undef and assigning the array to an empty array as the same operation. (Someone will probably correct me if I'm wrong.)
You're wrong :-) undefing the array will free the memory associated with the array back to the arena to be reused later. @array = (); does not free the memory used by the array. This has the primary advantage of saving allocation later if you're continually putting stuff in the array then clearing it. (i.e. perl doesn't need to regrow the array each time you put stuff in it after it has been cleared)
But ... both of them make the array empty, so if that's all you meant by "the same operation", then you're okay. ;-)
|
|---|