Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86298 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79720 invoked from network); 18 May 2015 23:07:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 May 2015 23:07:49 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.22 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.22 mout.gmx.net Received: from [212.227.17.22] ([212.227.17.22:64230] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/00-13816-3C07A555 for ; Mon, 18 May 2015 19:07:48 -0400 Received: from [192.168.0.101] ([88.134.68.210]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MI8iw-1YsqmE0Iqk-003yF5; Tue, 19 May 2015 01:07:44 +0200 Message-ID: <555A70C1.9000409@gmx.de> Date: Tue, 19 May 2015 01:07:45 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Dan Ackroyd CC: PHP Internals References: <55567DD2.1090608@gmx.de> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:tvxyFbMrNYuUBm34ZCFl7u2kXhvPyAbdV9VdcvRjwYYi7VuS5RH PrF8JVR9x67boielcrstMHeXDPmap9Eocl5C/WBcbeQgwXamMtQnXZP12shhe2o5o6mp6Su USa3qcV0SfZTQ8SO2eFZpAiQt5tpomaoknWAv5XKAEBdQyYg01GsitwgPL1Wlg6gC4b6SJG 8eLrT1yWE1qDUICk53yTQ== X-UI-Out-Filterresults: notjunk:1; Subject: Re: [PHP-DEV] trigger GC before memory limit is exhausted From: cmbecker69@gmx.de (Christoph Becker) Dan Ackroyd wrote: > On 15 May 2015 at 23:14, Christoph Becker wrote: > >> I wonder why the GC is not triggered when the memory limit is exhausted, > > To hopefully point you in the right direction, I believe the problem I > ran into, and the issue that stops it being a trivial thing to fix is > this; it can be necessary for memory allocations to take place inside > gc_collect_cycles. > > For example when an object has a userland __destruct method, and it is > destroyed when the GC runs, then calling that method should require > allocations.....but we've already run out of memory, so that can't > happen. Ah, I see! Thanks, Dan. Having given that some thought, I can understand that the issue has not been addressed yet. > As Rasmus suggested[1], in an issue linked through #60982, a simple > way to solve this would be to have both a soft and hard limit for > memory, and to allow the soft-limit to be a user callback, which could > call gc_collect_cycles, or not as the user desired. What happens if the soft limit is exhausted, but the GC can free only a little memory? That might trigger the GC shortly afterwards again and again. A user would have to carefully adjust the soft limit dynamically, to work around this problem. Then again, it might be better than the current situation. > However, it might be time to give the garbage collector a bit of love > and care, as it's not necessarily the case that the GC requirements > for PHP running as CGI process are the same as it running as a > long-running CLI process. I fully agree. > If nothing else, it would be nice to get the GC_BENCH benchmark stuff > working for the CLI again; it currently only works in certain > circumstances[2]. That doesn't seem to work on Windows at all (at least for current master). :( > [1] > [2] -- Christoph M. Becker