Re: Trapping "memory exhausted" error

From: Date: Wed, 18 Apr 2007 07:37:55 +0000
Subject: Re: Trapping "memory exhausted" error
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-28914@lists.php.net to get a copy of this message
On 4/17/07, Richard Lynch <ceo@l-i-e.com> wrote:
On Tue, April 17, 2007 3:16 am, David Sklar wrote: Richard Lynch <ceo@l-i-e.com> wrote:
You might also come at it from the other direction and detect/notify at some number smaller than the current hard limit, configurable in php.ini... This might play better with anything relying on the current behaviour
This is interesting and might actually take care of a lot of cases. I don't know enough about the existing memory manager to know if it would handle the case where a single new allocation would blow through both the (lower) soft limit and the hard limit at the same time. If an allocation blows through the hard limit, it should behave exactly as it does now, for BC, imho. If you let the developer decide on a "soft limit" or a percentage of the "hard limit" where some callback function happens, it's on their heads if they do something silly that rips right past their selected soft/hard limits.
Well, the BC case could be handled by doing what you suggest if the "grace limit" config option isn't defined. I think it's important, in the case that the grace limit is set up, to trigger its behavior even if a single allocation blows away both so that the recovery can be graceful. For example, if you're retrieving a feed to parse or the contents of a file and that feed or file is unexpectedly large so it blows through both memory limits. David

« previous php.internals (#28914) next »