Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66476 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84093 invoked from network); 5 Mar 2013 19:00:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2013 19:00:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.54 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.219.54 mail-oa0-f54.google.com Received: from [209.85.219.54] ([209.85.219.54:64235] helo=mail-oa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/24-58003-0C046315 for ; Tue, 05 Mar 2013 14:00:18 -0500 Received: by mail-oa0-f54.google.com with SMTP id n12so11314674oag.27 for ; Tue, 05 Mar 2013 11:00:11 -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=YHbHnCi8lg6UvA5Hbj3eVZXK6J4dX4gp0lpCI1/w6gM=; b=Zpbzby7SPudLh1tNJnxdWb7x8zB1KC+ao57t2OEKU1lEA5A0qpqXJZFN0uoWBtUNnX EuhCs4AuMVMqcZfP2jfgJGHi3m7034FHwrz5X3MpnhB8Wd7GNWrmJQMHNcyRliJSnmDt 0KkS7HpekkPgYZwQ5Z39UTtwpU4nGK93v0A+/Y66VGSnCu7FY1Hdpv1O0TPnbT4j9gUm ioAeuMUWqDszAgl1kMoyldkfw8i458gzAu9ONmKzULEvFF1dko5Oc1JcN6PtgC/uNb8l GPCoWTr78lpffrwwCBXqayEKL06EYCfYzm0qyAwVN1Ka6L/3b8d6KY6y8KSrSdn4Hflc c45A== X-Received: by 10.60.11.228 with SMTP id t4mr9336069oeb.42.1362510010501; Tue, 05 Mar 2013 11:00:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.76.113.178 with HTTP; Tue, 5 Mar 2013 10:59:50 -0800 (PST) In-Reply-To: References: <0f1001ce19ce$8ce5a260$a6b0e720$@starin.biz> Date: Tue, 5 Mar 2013 19:59:50 +0100 Message-ID: To: Tom Boutell Cc: nathan@starin.biz, internals@lists.php.net Content-Type: multipart/alternative; boundary=e89a8fb1ed062dda6e04d73215bc Subject: Re: [PHP-DEV] Memory warning hook From: linepogl@gmail.com (Lazare Inepologlou) --e89a8fb1ed062dda6e04d73215bc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 is triggered when the memory consumption reaches a threshold. 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. > On Tue, Mar 5, 2013 at 1:23 PM, wrote: > > As PHP applications are turning into large frameworks one of the issues > > arriving is memory management. One of the issues is that many framework= s > use > > sophisticated caching techniques to make accessing the same data quickl= y, > > 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 place = 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 will = be > > called before the GC is executed which allows the user to try and free = up > > some memory on their own. This hopefully would give more flexibility to > > allowing these advanced caching techniques but at the same time allow t= he > > 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=C3=A9nieur Logiciel --e89a8fb1ed062dda6e04d73215bc--