Hi Bill,

On Wed, 7 Feb 2001, Bill Moseley wrote:

> I'm using some C extensions in my mod_perl application.  IIRC, memory used
> by perl is never given back to the system.  Does this apply also to
> malloc() and free()ed memory in my C extension?  Or is that OS dependent?

It's not clear from your post whethere you're using C to extend Apache
or Perl.  If it's Apache you should be using pools for efficiency's
sake.  There are two sorts of pools (at least:) - those which live for
the lifetime of the parent and those which live for the lifetime of
the child.

If you're using XS then you probably should be using the New(), Newc()
etc. interface to malloc().  See 'perldoc perlapi', 'perldoc perlguts'
and 'perldoc perlxs'.  I guess you already have?

If hacking Perl then you can probably do what you like.

Quote from 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.

Eeek!

If you use plain old C malloc() then unless it's been replaced by the
Perl version (which I think they'd like) you'll get your memory back
OK.  Simple enough to check with 'top'.

> Can Apache ever shrink?

If you use plain malloc, yes.  You free some of the the Apache and
Perl pools when a child dies.

See also apache/htdocs/manual/new_features_1_3.html - look for "ALLOC_DEBUG".

HTH

73,
Ged.

Reply via email to