468,321 Members | 1,669 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

Freeing up memory by undefining perl variables

hi,
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
1 4920
KevinADC
4,059 Expert 2GB
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.

Similar topics

5 posts views Thread by disco | last post: by
11 posts views Thread by Rodrigo Dominguez | last post: by
6 posts views Thread by Fernando Cacciola | last post: by
4 posts views Thread by Atul Sureka | last post: by
5 posts views Thread by Amogh | last post: by
2 posts views Thread by Chris | last post: by
6 posts views Thread by Praetorian | last post: by
3 posts views Thread by Mad Hatter | last post: by
11 posts views Thread by vivek | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.