Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47948 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8182 invoked from network); 15 Apr 2010 07:15:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2010 07:15:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=tly.phpfans@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tly.phpfans@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.221.173 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tly.phpfans@gmail.com X-Host-Fingerprint: 209.85.221.173 mail-qy0-f173.google.com Received: from [209.85.221.173] ([209.85.221.173:53106] helo=mail-qy0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/92-20494-61DB6CB4 for ; Thu, 15 Apr 2010 03:15:35 -0400 Received: by qyk4 with SMTP id 4so1158390qyk.17 for ; Thu, 15 Apr 2010 00:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type; bh=VY/kIdY8udIvaEmdMqPYjH1+pkSTOcCuRJOUHz7l9Y4=; b=FQMpkCtNEU7belJjaQIhxOQZX+RfGF66LdoAO1q32YMH4gnItABcDP9uuvlw8YLyCI dgV+s0CoDQqUI9BZL7BTfvEnN2mMGQaJyxpVBjRoJxADrYKZgmy5fAJtz+0OL5mQMyET rGFvf369ZiQWo5wgo7spkOEfTHFvCtCgCCmkg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=GHkseR9QrFnYqLDgBjfkTsfaNF2oS7BNqR48S+reOfFN3acPJLwPKRaonr7Mc4fCov JimtASgZQU7pktaXQ9gHMvsI6PBCm6yakeF21OnmX6NWrmm2/6RD1WLPejRr2Yw4Vd5t 2KvqxWcRF8J79vtX62e6q6pJQ1i8RgIEDe//Y= MIME-Version: 1.0 Received: by 10.224.80.146 with HTTP; Thu, 15 Apr 2010 00:15:14 -0700 (PDT) In-Reply-To: References: <4BC58D10.4050609@lerdorf.com> Date: Thu, 15 Apr 2010 15:15:14 +0800 Received: by 10.224.80.87 with SMTP id s23mr3054593qak.70.1271315714719; Thu, 15 Apr 2010 00:15:14 -0700 (PDT) Message-ID: To: =?ISO-8859-1?B?Suly9G1lIExveWV0?= Cc: Rasmus Lerdorf , internals@lists.php.net Content-Type: multipart/alternative; boundary=001636137aa292c201048441419d Subject: Re: [PHP-DEV] One suggestion to PHP-FPM From: tly.phpfans@gmail.com (looyao teng) --001636137aa292c201048441419d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable When allocate memory from PHP memory heap, PHP runtime check the memory_limit which in php.ini, but this can only give a error message and not to continue to excute php code, it can't control the PHP-FPM child process, my idea is that when the memory out of limit we set, kill this child process, we know, though PHP runtime can free its heap memory, but it can't give it back to the system, so we can kill this child process and ensure the system have enough free memory. We do check the memory limit is to control the process. 2010/4/15 J=C3=A9r=C3=B4me Loyet > 2010/4/15 =E6=BB=95=E8=B7=AF=E9=81=A5 : > > We check error log after our server crashed, and we found that php heap > > memory is out of limit, > > so I think imagick use emalloc to allocate php heap memory, to check th= e > > zend_memory_usage is > > not a method for imagick, other circumstances which occupy huge memory > can > > use this method to > > ensure the system have enough free memory. > > OK, > > one thing I didn't understand is "why should you want check de zend > memory usage when there is a memory_limit parameter in PHP.ini " ? > does'nt it do the same at PHP layer when allocating ? > > > > > thanks, > > looyao > > > > 2010/4/14 Rasmus Lerdorf > >> > >> On 04/14/2010 02:01 AM, J=C3=A9r=C3=B4me Loyet wrote: > >> > The patch seems good (I didn't test it yet) but I'm curious about th= e > >> > way you check the memory real size: > >> > > >> > + if(zend_memory_usage(1 TSRMLS_CC) > > >> > fpm_global_config.term_on_memory_limit){ > >> > > >> > I don't know much about the zend_memory_usage() function. But does i= t > >> > return the real memory size of the process ? > >> > >> Right, that will only give you the memory allocated by the memory > >> manager, obviously. But, pecl/imagick does seem to use emalloc to > >> allocate the imagick objects. However, if the underlying magickwand > >> library mallocs a bunch of temporary space on its own, this will not g= et > >> picked up. > >> > >> -Rasmus > > > > > --001636137aa292c201048441419d--