cvs commit: perlfaq perlfaq3.pod

[email protected] 31 Jan 2005 15:52:49 -0000
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     05/01/31 07:52:47

  Modified:    .        perlfaq3.pod
  Log:
  * Michael Carmen rewrote this answer to clarify some of the memory
  management issues.  I usually don't pay attention to this level of
  Perl and I'm not an OS guru, so an internals-type person may want
  to verify the change.
  
  Revision  Changes    Path
  1.45      +19 -17    perlfaq/perlfaq3.pod
  
  Index: perlfaq3.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq3.pod,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- perlfaq3.pod	21 Jan 2005 12:08:04 -0000	1.44
  +++ perlfaq3.pod	31 Jan 2005 15:52:47 -0000	1.45
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq3 - Programming Tools ($Revision: 1.44 $, $Date: 2005/01/21 12:08:04 $)
  +perlfaq3 - Programming Tools ($Revision: 1.45 $, $Date: 2005/01/31 15:52:47 $)
   
   =head1 DESCRIPTION
   
  @@ -649,23 +649,25 @@
   
   =head2 How can I free an array or hash so my program shrinks?
   
  -You usually can't. On most operating systems, memory
  -allocated to a program can never be returned to the system.
  -That's why long-running programs sometimes re-exec
  -themselves. Some operating systems (notably, systems that
  -use mmap(2) for allocating large chunks of memory) can
  -reclaim memory that is no longer used, but on such systems,
  -perl must be configured and compiled to use the OS's malloc,
  -not perl's.
  -
  -However, judicious use of my() on your variables will help make sure
  -that they go out of scope so that Perl can free up that space for
  -use in other parts of your program.  A global variable, of course, never
  -goes out of scope, so you can't get its space automatically reclaimed,
  -although undef()ing and/or delete()ing it will achieve the same effect.
  +(contributed by Michael Carman)
  +
  +You usually can't. Memory allocated to lexicals (i.e. my() variables)
  +cannot be reclaimed or reused even if they go out of scope. It is
  +reserved in case the variables come back into scope. Memory allocated
  +to global variables can be reused (within your program) by using
  +undef()ing and/or delete().
  +
  +On most operating systems, memory allocated to a program can never be
  +returned to the system. That's why long-running programs sometimes re-
  +exec themselves. Some operating systems (notably, systems that use
  +mmap(2) for allocating large chunks of memory) can reclaim memory that
  +is no longer used, but on such systems, perl must be configured and
  +compiled to use the OS's malloc, not perl's.
  +
   In general, memory allocation and de-allocation isn't something you can
  -or should be worrying about much in Perl, but even this capability
  -(preallocation of data types) is in the works.
  +or should be worrying about much in Perl.
  +
  +See also "How can I make my Perl program take less memory?"
   
   =head2 How can I make my CGI script more efficient?