PHP out of memory error even though memory_limit not reached
I have just inherited a site with a PHP script that is consistently running out of memory at 117 MB. This happens even when I increase PHP's memory_limit variable to 312 MB, which I'm doing via php.ini. This is now solved thanks to a great clue from pcguru. See my answer below that begins: I have finally found the answer ini_get('memory_limit') returns the value set in php.ini, so I'm certain Apache has restarted after changing the value. I'm using memory_get_usage(true) to return the memory consumed by the script at various points along the way. And it's consistently failing when it gets to