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.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊


In reply to Re^3: How to destroy variables and hash? by diotalevi
in thread How to destroy variables and hash? by PerlPhi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.