Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Mini-Tutorial: Perl's Memory Management

by wfsp (Abbot)
on Oct 28, 2009 at 11:26 UTC ( #803660=note: print w/ replies, xml ) Need Help??


in reply to Mini-Tutorial: Perl's Memory Management

Lexical variables don't get freed at end of scope. They are cleared on scope exit...
From then on in I was lost. What the difference is between "freed" and "cleared" or "end" and "exit" is in this context defeats me (and I'm not absolutely sure about lexical). Obscure in the extreme without a far deeper explanation of the subject. And that is just the second paragraph. :-)

The title says "Mini-Tutorial: Perl's Memory Management". I would hope this is not included as or referred to as a faq/tutorial for scope or references, there are far friendly ways to do this.


Comment on Re: Mini-Tutorial: Perl's Memory Management
Re^2: Mini-Tutorial: Perl's Memory Management
by oha (Friar) on Oct 28, 2009 at 13:36 UTC
    I personally think that just givin a brief preamble on what are the differences between "freed" and "cleared" as for "end" and "exit" would make the document very usefull.

      I agree, this would be much improved by some definitions. I read a lot of it thinking, "what is meant by 'free' here?".

      I think often times when questions about memory arise, a focus of interest is on when and how memory is returned to the operating system. That's probably a distinction made in here somewhere, but it would be better if that distinction were explicit.

Re^2: Mini-Tutorial: Perl's Memory Management
by Anonymous Monk on Oct 28, 2009 at 14:17 UTC
    'free memory' is when you give up the memory block back to the OS,

    'clear memory' is when you, for instance, say @a = ();, the variable still there but without content.

    as ikegami said, perl does not free memory, so look at free in C if you still don't understand..
      for what i understood i disagree, there are 3 phases:

      clear release the bind of the data to the variable

      free the data is released to the mem manager so can be reused by perl

      free to OS may happen in some cases after the free.

      Where the first 2 are how perl behave, and the last depends on the system (OS + how perl was compiled)

      Am i wrong?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2014-11-26 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (173 votes), past polls