Re: [PHP-DEV] PHP4: php_module holds memory to long ! From: Stig Venaas (Stig.Venaas <email protected>)
Date: 01/10/01

On Wed, Jan 10, 2001 at 09:23:43PM +0200, Stanislav Malyshev wrote:
> SS>> Thanks for the correction! I have never seen that in action
> SS>> though. Usually, the C library will keep freed memory in
> SS>> free lists and does not decrease the size of the data
> SS>> segment using sbrk.
>
> Actually, from glibc source there's a hook that is supposed to do this in
> some circumstances. Never could actually make it work in real life. Also,
> IIRC glibc on Linux allocates really large (8k+? 16k+?) blocks as mmap's
> of /dev/zero and those are really given back to system, since on free they
> are just munmap'ed.

Checked the glibc 2.2 sources, looks like 128k+ blocks are mmap'ed and
given back to the system.

How does Zend allocate memory then? I guess I could try to figure it
out myself, but it's a bit complex. Are there many small chunks? Seems
like emalloc() is called a lot creating small chunks, but each emalloc()
doesn't result in a corresponding malloc() perhaps? I guess with glibc
on Linux it would be nice if malloc() allocated say 128k chunks, and
emalloc() used memory inside those.

Stig

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>