Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl memory manager

Reply
Thread Tools

Perl memory manager

 
 
Nishant
Guest
Posts: n/a
 
      01-03-2008
Hi ,
My understanding about the perl memory manager is that it initially
allocates a chunk of memory and allocates more memory when required.
but it does not return the whole memory to the OS. Rather, it keeps it
with itself ,so that the next time it has to use memory , it can use
it from the already chunk of memory that it has. Is my understanding
correct ? If yes, in what all scenarios does perl return memory back
to OS and scenarios in which it does not return.
Also, what is the size of the chunk of the memory that perl allocates
at one time. Is it variable ?

Regards
Nishant Sharma
 
Reply With Quote
 
 
 
 
Joost Diepenmaat
Guest
Posts: n/a
 
      01-03-2008
Nishant <> writes:

> Hi ,
> My understanding about the perl memory manager is that it initially
> allocates a chunk of memory and allocates more memory when required.
> but it does not return the whole memory to the OS. Rather, it keeps it
> with itself ,so that the next time it has to use memory , it can use
> it from the already chunk of memory that it has. Is my understanding
> correct ?


In general, yes, your understanding is correct.

> If yes, in what all scenarios does perl return memory back
> to OS and scenarios in which it does not return.


In my experience it depends on the OS and possibly also on the malloc
implementation that your perl interpreter is configured with.

As a quick guideline you should assume *no* memory is ever returned to
the OS except when the program exits or is replaced by another program
via exec.

In certain cases you can get memory back to the OS by just letting
variables go out of scope, for instance:

for (@someting) {
my @x = some_really_long_strings();
}

may or may not release @x's memory to the OS when the loop is done.

Sometimes explicitly undefining collections works when scoping by itself
doesn't:

my @x;
for (@someting) {
@x = some_really_long_strings();
}
undef @x;

This works at least in some cases on some versions of perl on some linux
systems. You'll just have to test it yourself to be sure.

> Also, what is the size of the chunk of the memory that perl allocates
> at one time. Is it variable ?


I'm pretty sure it's variable. Allocating hundreds of small chunks just
to get a single big chunk would be stupid. Things like arrays, strings
and hashes all need continous chunks of memory of unpredictable sizes.

Joost.
 
Reply With Quote
 
 
 
 
Ilya Zakharevich
Guest
Posts: n/a
 
      01-03-2008
[A complimentary Cc of this posting was sent to
Nishant
<>], who wrote in article <ebe644b7-62d8-463f-b378->:
> Hi ,
> My understanding about the perl memory manager is that it initially
> allocates a chunk of memory and allocates more memory when required.
> but it does not return the whole memory to the OS. Rather, it keeps it
> with itself ,so that the next time it has to use memory , it can use
> it from the already chunk of memory that it has. Is my understanding
> correct ?


No. What you wrote is applicable to Perl configured with mymalloc.
Perl's compiled with system malloc() will behave differently.

> Also, what is the size of the chunk of the memory that perl allocates
> at one time. Is it variable ?


This is kinda documented somewhere. About 10 years ago, mymalloc
default was to start with about 48K, then increase in >= 3% increments.
Configurable at compile time.

Hope this helps,
Ilya
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cisco 1750 Router Cisco QoS Device Manager Cisco VPN Device Manager Rene Kuhn Cisco 0 12-28-2005 08:45 PM
Cisco CW Campus Manager, CW Common Service, CW Device Fault Manager, CW Recource Manager Essentials, NGenious RealTime Monitor, CiscoWorks Routed WAN Management Solution v1.3 [3 CDs], CiscoWorks VPN_Security Management Solution v2.2, CiscoWorks QoS P astra35 Cisco 0 05-19-2004 01:01 PM
Help!!How to upgrade campus manager 3.1 in ciscoworks 2000 LMS to campus manager 3.3? zll9527 Cisco 1 02-26-2004 01:14 AM
Cisco CW Campus Manager, CW Common Service, CW Device Fault Manager, CWRecource Manager Essentials, NGenious RealTime Monitor, CiscoWorksRouted WAN Management Solution v1.3 [3 CDs], CiscoWorks VPN_SecurityManagement Solution v2.2, CiscoWorks QoS Poli TEL Cisco 0 01-17-2004 07:09 AM
Cisco CW Campus Manager, CW Common Service, CW Device Fault Manager, CWRecource Manager Essentials, NGenious RealTime Monitor - new ! TEL Cisco 0 12-31-2003 07:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57