|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-10-19 19:15 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 14:00:02 2025 UTC |
Description: ------------ I have a PHP production setup where errors are automatically reported to me via email, by using a custom error handler. However, when PHP reaches it's memory limit the custom error handler is disabled. As a result, I may not be notified of OOM errors. It would be nice if PHP did one of two things: 1) Emit an E_WARNING the first time the script reaches 99% (or something like that, maybe configurable) of memory_limit. 2) When the program reaches the memory limit the first time, add fx 1MB (perhaps user configurable) to the memory limit, emit an OOM E_WARNING, and let the custom error handler handle the error. The next time the memory limit is reached then really die. I would prefer 1) Reproduce code: --------------- <?php function custom_error_handler($error_code, $error_string, $filename, $line, $symbols) { die("This is the custom error handler"); } set_error_handler('custom_error_handler'); $i = 0; $a = Array(); while (true) { $a[$i] = $i++; } ?> Expected result: ---------------- It would be nice if my custom error handler was allowed to run. Actual result: -------------- t@t ~/php_oom> php test.php Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 35 bytes) in /home/thue/php_oom/test.php on line 10