Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66477 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88517 invoked from network); 5 Mar 2013 20:08:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2013 20:08:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wg0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:33999] helo=mail-wg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/E4-58003-0C056315 for ; Tue, 05 Mar 2013 15:08:33 -0500 Received: by mail-wg0-f42.google.com with SMTP id 12so3669884wgh.5 for ; Tue, 05 Mar 2013 12:08:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=2+/dGq3Tji1n24df0AEbaB+wfe+V9MSWtI97+MZ4IHE=; b=QS/R3yT7MFE85bcJ8iRATWjfMmTcOmDoBOS+oe3mn5I+Zq+GBAClVwU+bZWA0lbIpQ 0/ASgrD0cLJ7epn72/89VIpLFHu0zpPYWXd4tOhw+VnYZR/btq62qxsFx1hzE4OEz8ED F+UejfG5Ogn2zvThUtSPhny1DniorBnOKah04u0axKK+F9vw1tE4JvmT9m//iUEurdst K4vHrERe+VGe1ZjtVCOhHWBcTl6BXWWjYEW3DyVkRZta35zyq0lB1SXbMdwogu96Js6s tgOiLjhSgNDoBTH8fDW9Inr0OMqJIMhaOnitNLEO5/PttTghkp9UuYKXYTV2am1GTahD T4sQ== X-Received: by 10.180.82.70 with SMTP id g6mr21080402wiy.21.1362514109275; Tue, 05 Mar 2013 12:08:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.69.149 with HTTP; Tue, 5 Mar 2013 12:08:08 -0800 (PST) In-Reply-To: References: <0f1001ce19ce$8ce5a260$a6b0e720$@starin.biz> Date: Tue, 5 Mar 2013 21:08:08 +0100 Message-ID: To: Lazare Inepologlou Cc: Tom Boutell , nathan@starin.biz, PHP internals list Content-Type: multipart/alternative; boundary=f46d044267267c27ca04d73309fe Subject: Re: [PHP-DEV] Memory warning hook From: krebs.seb@gmail.com (Sebastian Krebs) --f46d044267267c27ca04d73309fe Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2013/3/5 Lazare Inepologlou > 2013/3/5 Tom Boutell > > > Can't you do this already? memory_limit can be fetched via ini_read, > > and together with memory_get_usage you should be able to check for > > this sort of thing. Admittedly having to parse memory_limit (which can > > be in various units) is not perfect. > > > > This is not the same at all. When are you going to run this code? Memory > allocations happen all the time. What Nathan asked for is an event that i= s > triggered when the memory consumption reaches a threshold. > You can use ticks :) http://php.net/control-structures.declare#control-structures.declare.ticks > > However, there is a different solution, which is better IMHO in the case = of > caches: weak references. A weak reference automatically frees the memory = of > the object, when the memory is needed. > http://php.net/manual/en/book.weakref.php. > > Having said that, none of these solutions scale up to multiple servers. > This is why shared cache systems like memcached are recommended. > Well, maybe I don't understand, what you are trying to tell, but if you run out of memory, this of course only affects one server on its own. > > > > > > On Tue, Mar 5, 2013 at 1:23 PM, wrote: > > > As PHP applications are turning into large frameworks one of the issu= es > > > arriving is memory management. One of the issues is that many > frameworks > > use > > > sophisticated caching techniques to make accessing the same data > quickly, > > > this improves speed it is at the cost of memory. Often the developer > > knows > > > these areas that cache and often times already have functions in plac= e > to > > > clear out the cache, however in the case where PHP is approaching or > > exceeds > > > memory limits PHP runs the GC then dies if it cannot allocate enough > > memory. > > > If we implemented "memory warning" triggers or user function that wil= l > be > > > called before the GC is executed which allows the user to try and fre= e > up > > > some memory on their own. This hopefully would give more flexibility = to > > > allowing these advanced caching techniques but at the same time allow > the > > > cache to be cleared out in case memory is getting low. > > > > > > > > > > > > Thoughts? > > > > > > > > > > > > Thanks, > > > > > > Software Developer > > > > > > Nathan Bruer > > > > > > > > > > > > > > > > > -- > > Tom Boutell > > P'unk Avenue > > 215 755 1330 > > punkave.com > > window.punkave.com > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > Lazare INEPOLOGLOU > Ing=E9nieur Logiciel > --=20 github.com/KingCrunch --f46d044267267c27ca04d73309fe--