Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: How to destroy variables and hash?

by diotalevi (Canon)
on May 17, 2007 at 20:42 UTC ( [id://616107]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to destroy variables and hash?
in thread How to destroy variables and hash?

I have a suspicion that you've asked a question in a way that's elicited an misleading answer from zentara. It's true what he said about unreferenced things possibly being interleaved in memory but generally speaking this doesn't matter. In normal perl you never have to deal with memory management issues like allocation and only in unusual circumstances, deallocation. Perl is never going to re-use memory that is still in use by something else. If that's your worry, you're safe. Also, you don't have to take steps to inform perl that data structures may be deallocated. Perl's reference counting is frequently good enough though it has no way to deal with cyclic structures.

The only time you ought to find it necessary to be specific about freeing memory is when you're leave code you don't intend to re-enter again and it is somehow important to you to remove the empty containers. This sometimes comes up when you've got some very large hashes or arrays and you know you're not going to use it again and the memory is significant enough to notice. In that circumstance, you can use the undef() function on your variables and it will delete the containers. Normally perl will just clear away the data within your containers because often you're going to be re-using them when you're in a subroutine or a loop.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

  • Comment on Re^3: How to destroy variables and hash?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://616107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-23 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found