I have a PHP script when the user submits a form which leads to an SQL query which, sometimes, exceeds the limit of memory PHP is entitled to use (which is 128M). The very specific line of code is the following : $rows = $db->fetchAll($select);
(I'm using ZF1.12).
I have read everything that is possible to read on the subject, however I cannot figure out how to track the memory usage. I am aware of the memory_get_usage(true)
and memory_get_peak_usage(true)
functions which allow to monitor the memory PHP is currently using (but these give me values around ~13Mb which is far less than the limit of 128M). I have also tried to handle the fatal error with register_shutdown_function()
but I would like to handle the probleme before the fatal error occurs.
I also don't want to increase the value via ini_set()
nor .htaccess
nor editing php.ini
file.
Therefore, my question is : how can I monitor the memory PHP is currently using and do what I want to do before the limit is reached ?
PS : I have basically the same problem than this user but I don't want to catch Fatal Error, I want to do specific stuff before it occurs.