Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Using Perl's Malloc

by zentara (Archbishop)
on Jan 06, 2005 at 13:03 UTC ( #419897=perlquestion: print w/replies, xml ) Need Help??

zentara has asked for the wisdom of the Perl Monks concerning the following question:

The post in Memory leaks and reference counting within Perl. jogged my memory about something I read in perldoc perlguts.

"It is suggested that you enable the version of malloc that is distributed with Perl. It keeps pools of various sizes of unallocated memory in order to satisfy allocation requests more quickly. However, on some platforms, it may cause spurious malloc or free errors."

So when I build Perl, it askes if I want to use Perl's malloc or the system's malloc, with it defaulting to system. Is there beter memory performance with Perl's malloc, and if so, what improvements could I expect on linux?

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re: Using Perl's Malloc
by osunderdog (Deacon) on Jan 06, 2005 at 15:38 UTC
Re: Using Perl's Malloc
by mkirank (Chaplain) on Jan 06, 2005 at 13:33 UTC
Re: Using Perl's Malloc
by eyepopslikeamosquito (Bishop) on Jan 07, 2005 at 03:17 UTC

    Generally, it's risky to change Configure's default malloc for your platform. I've noticed a trend over the past couple of years when running perl's Configure towards using the system malloc -- I guess so as to be bug-compatible with system and 3rd party libraries (for example, Perl's free() may crash when given an invalid address by a buggy library while the system malloc may be more forgiving).

    As for Linux, I noticed this in hints/

    # The system malloc() is about as fast and as frugal as perl's. # Since the system malloc() has been the default since at least # 5.001, we might as well leave it that way. --AD 10 Jan 2002

    From perl58delta:

    If your pointers are 64 bits wide, the Perl malloc is no longer being used because it does not work well with 8-byte pointers. Also, usually the system mallocs on such platforms are much better optimized for such large memory models than the Perl malloc. Some memory-hungry Perl applications like the PDL don't work well with Perl's malloc. Finally, other applications than Perl (such as mod_perl) tend to prefer the system malloc. Such platforms include Alpha and 64-bit HPPA, MIPS, PPC, and Sparc.

    Finally, this reference may be of interest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://419897]
Approved by Courage
Front-paged by Courage
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2021-01-19 21:45 GMT
Find Nodes?
    Voting Booth?