Freeing up memory by undefining perl variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pavanponnapalli
    New Member
    • May 2008
    • 51

    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
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    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.

    Comment

    Working...