Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16643 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58195 invoked by uid 1010); 13 Jun 2005 22:15:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 58179 invoked from network); 13 Jun 2005 22:15:59 -0000 Received: from unknown (HELO pb1.pair.com) (127.0.0.1) by localhost with SMTP; 13 Jun 2005 22:15:59 -0000 Received: from ([127.0.0.1:6210]) by pb1.pair.com (ecelerity 1.2 r(5656M)) with ECSTREAM id E3/4E-20931-4950EA24 for ; Mon, 13 Jun 2005 18:15:48 -0400 X-Host-Fingerprint: 144.140.93.195 omta05sl.mx.bigpond.com Solaris 8 (2) Received: from ([144.140.93.195:38156] helo=omta05sl.mx.bigpond.com) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id FA/D2-20931-A3B8BA24 for ; Sat, 11 Jun 2005 21:09:15 -0400 Received: from mail.mel.tellusion.com ([61.9.138.217]) by omta05sl.mx.bigpond.com with SMTP id <20050612010909.CTSG4114.omta05sl.mx.bigpond.com@mail.mel.tellusion.com> for ; Sun, 12 Jun 2005 01:09:09 +0000 Received: by mail.mel.tellusion.com (Postfix, from userid 31337) id D4BF94D78002; Sun, 12 Jun 2005 09:30:23 +1000 (EST) Received: from 192.168.2.20 ([192.168.2.20]) (SquirrelMail authenticated user ap); by mail.tellusion.com with HTTP; Sat, 11 Jun 2005 16:30:23 -0700 (PDT) Message-ID: <.192.168.2.20.1118532623.squirrel@192.168.2.20> Date: Sat, 11 Jun 2005 16:30:23 -0700 (PDT) To: internals@lists.php.net User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 (Normal) Importance: Normal Content-Transfer-Encoding: quoted-printable Subject: PHP memory fragmentation From: ap@tellusion.com ("Andrew Prendergast") Hey Folks, I'm not on the list so please reply back to my email. I have been having some problems with memory fragmentation in PHP when working with large data structures. Once a script finishes executing, although the garbage collector technically has freed the ram, the pages are still allocated. The next time the thread executes, there is a whole pile of swapping and if a memory hungry script gets run again, the memory footprint increases. Now consider what happens when I have 20 processes in an FCGI pool, each one getting above 300MB in size, its not good. My solution which I have implemented as part of the FCGI SAPI (thanks to GeorgeS, hartmut, Pierre & Derick for their guidance) is the introduction of two new environment variables, PHP_FCGI_MAX_RAM_MB & PHP_FCGI_MAX_RAM_INCREASE. PHP_FCGI_MAX_RAM_MB allows one to set a limit (in megabytes) of how large an FCGI process is allowed to grow to. PHP_FCGI_MAX_RAM_INCREASE allows one to set a maximum % increase compared to when the process first started. If either of these limits are exceeded, the process will be restarted AFTER script execution has completed (unlike the --enable-memory-limit stuff). Please get back to me on: 1. your thoughts on this 2. an idea of how big an average PHP process should be (mine are 150MB when they start, 160MB after running some average scripts, and grow to above 300 MB when working with big data structures and complex object caching code) 3. how do i get this back into the PHP source tree! (sorry newbie) Regards, ap.