Re: Trapping "memory exhausted" error

From: Date: Tue, 17 Apr 2007 08:18:12 +0000
Subject: Re: Trapping "memory exhausted" error
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-28878@lists.php.net to get a copy of this message
On 4/17/07, Peter Hodge <toomuchphp-phpdev@yahoo.com> wrote:
Hello, A soft memory limit could be very useful; it doesn't necessarily need to throw an error, but it would provide an opportunity to free some memory and prevent the script from crashing. Perhaps something like: // function to call when memory is running out register_memory_limit_handler('freeSomeMemory'); function freeSomeMemory() {
    $GLOBALS['someBigCache'] = null;
}
My intention with the grace limit was to provide a graceful way of failing, not to continue processing in a reduced state -- as Stanislav said above, it could be difficult to do a lot after the allocation has failed. David

« previous php.internals (#28878) next »