By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,834 Members | 2,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,834 IT Pros & Developers. It's quick & easy.

Freeing up memory by undefining perl variables

P: 51
What is the difference between undef($variable_name) and
$vaiable_name = undef;? And is there any function in perl which dynamically deallocates the allocated memory for scalars? same question for lists and hashes.

Thanks & Regards,
Pavan Kumar
Sep 23 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 4,059
undef(variable) completely deletes the variable

variable = undef assigns the undef value to a variable

As far as I know if you do something like this:

$foo = 'some value';
$foo = ''; <-- frees up memory

@foo = (1..1000000);
@foo = (); <-- frees up the memory

I am not sure if you undef(variable) it will free up the memory. I don't know if there is a module that frees up memory.
Sep 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.