In PHP, when the script consume more than memory_limit value, the script stop with an error. How can I add a warning level: if my script consumes more than 90Mb I have a warning in the log file, but the script go on, and still crashes if it consumes more than 128Mb?
I know nothing about PHP extensions or PHP C code, but as long as we already build PHP by ourself, we can even patch the code.
In Zend/zend_alloc.c I can see this
if (segment_size < true_size || heap->real_size + segment_size > heap->limit) {
Really easy to add a line before this and compare used memory to another limit, and issue a warning.
Can I do this in an extension, or by patching the PHP code? Why this does not already exist? It is a bad idea? Does this already exist somewhere?
Adding the same warning for MAX_EXECUTION_TIME seem more difficult, as I still don't understand the way the timer is handled.