On Tue, April 17, 2007 3:18 am, David Sklar wrote: > On 4/17/07, Peter Hodge <[EMAIL PROTECTED]> 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.
And we are suggesting that PHP Developers be provided with hooks to anticipate failure BEFORE it happens, and to take pro-active measures to see that there is no failure, rather than have some kind of post-failure effort to do something. For example, perhaps one could register a hook function to be called when we are within 80% of the memory_limit setting, and another hook if we reach 90%. I presume one could just hack that with some kind of 'ticks' function and memory_get_usage, but it probably wouldn't be nearly as efficient as something more generic than the current hard failure in the engine. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php