At 08:37 AM 11/8/01 -0500, Etienne Marcotte wrote:
>(Related question)
>
>Doesn't it free the memory everytime a variable comes out of scope?
There are a few things being convolved in this thread.
No program on Unix can decrease its memory allocation. Once it's acquired
the memory, it keeps it until the program exits. When a Perl program or
any other program exits, the memory it used is returned to the free pool by
the operating system, not the language.
When the reference count on a piece of storage allocated by Perl drops to
zero (commonly, by a variable going out of scope), Perl marks the space it
used as being available for reallocation by its own internal memory
allocator. The memory is not returned to the operating system, nothing can
do that (on Unix, anyway). But the next time the Perl program needs some
memory, it can reuse this deallocated chunk without having to request more
from the OS.
>Isn't that the goal of my, besides not interferencing with a same name
>variable in the same package..
>
>....code...
>
>sub whatever {
>my $variable = "foo"; # takes memory
>....more code...
>}
># memory for $variable free
>.... more code...
>
>Etienne
>
>Rupert Heesom wrote:
> >
> > I'm writing a script which is using what may be a fair chunk of memory
> > during the script.
> >
> > Does Perl unallocate the memory used by the perl data structures
> > automatically at the end of each script, or do I have to unallocate /
> > free the memory manually? If manually, which commands are used?
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]