Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:4350 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35063 invoked by uid 1010); 2 Sep 2003 11:28:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35019 invoked from network); 2 Sep 2003 11:28:08 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 2 Sep 2003 11:28:08 -0000 Received: (qmail 5464 invoked from network); 2 Sep 2003 11:28:01 -0000 Received: from localhost (HELO zeev-laptop.zend.com) (127.0.0.1) by localhost with SMTP; 2 Sep 2003 11:28:01 -0000 Reply-To: zeev@zend.com Message-ID: <5.1.0.14.2.20030902142927.0662a258@localhost> X-Sender: zeev@localhost X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 02 Sep 2003 14:33:54 +0300 To: "Vesselin Atanasov" Cc: "PHP-DEV" In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] [PATCH] Disable the Zend memory cache From: zeev@zend.com (Zeev Suraski) References: At 12:46 02/09/2003, Vesselin Atanasov wrote: >Hello. >The memory cache code in zend_alloc.c has serious problems with memory >fragmentation. >When a big script is run which allocates both lots of small objects and >a few big objects, the memory cache grows until the allowed limits >(11 buckets x 256 blocks each) keeping all of the cached memory occupied >although >the script uses much less memory. This is caused by the cache code which >caches small >objects and does not allow the low level memory manager (either the >zend_mm.c or the >C runtime malloc) to merge small free blocks into bigger free blocks. From >the point >of view of the low level memory manager there are lots of occupied memory >blocks >interspersed among the allocated memory segment. the occupied memory >blocks are >actually cached by the high level cache code. So when the script is run a >new segment >is allocated although there is free memory. With each call new segment(s) >are allocated >until the memory cache is full. This scenario happens when a script first >creates lots >of small objects and then a few large objects. Even if the small objects >are freed, >the memory is fragmented and a new block is occupied for the big >object(s). So with >each request the lost memory increases, effectively this is like a memory >leak. >I attach a patch which adds --disable-memory-cache option which disables >the memory >cache. Vesselin, The memory fragmentation issues were reported by Sterling a few weeks ago - we know they're there. The simplest solution appears to be decreasing the zend_mm block size to 16KB instead of 256KB. Due to bugs elsewhere (libxml2), making this change appeared to cause problems, but with these bugs now fixed - it appears to work fine. After we perform some more benchmarks we'll commit this change. Disabling memory caching altogether is probably not a good idea since PHP allocates and frees small blocks VERY often. Zeev