Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

"should" sounds a bit dangerous to me. "Should be transparent" ... or so it's not always? It can fail? Or what? How? The "should" seems to cause uncertainty.

Mkay, let's see. If we declare the variable in a loop, we are about to do another iteration and there are no other references to the data, perl may clear the contents, but leave the structure (can't remember the name) and it doesn't have to allocate memory for that variable for the next iteration. Nice. Efficient. Now what does it do if it's not in any loop? Or it was the last iteration? What if it's a my variable inside a string eval""?

I believe your tutorial will only make sense if you first explain at least a bit about how are the data stored (the variable name points to a SV which points to the string/contains the number/whatever) and then you can go on explaining what's "cleared" or "freed" and what does the Devel::Peek::Dump mean.

Anyway for almost everyone the whole memory allocation tutorial should be "Declare variables with my in the tightest scope possible. Make sure you either do not create circular references, use weaken() to make sure at least one link in each circle is weak or break the circle by reseting at least one reference to undef. Do not expect perl to return the memory to the OS, but that doesn't mean the memory is not freed and will not be reused, it's just kept in perl's own hands. The rest is not your business."

Enoch was right!
Enjoy the last years of Rome.

In reply to Re^3: Mini-Tutorial: Perl's Memory Management by Jenda
in thread Mini-Tutorial: Perl's Memory Management by ikegami

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (3)
    As of 2020-10-24 04:04 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (242 votes). Check out past polls.