I have a request handler running in apache/mod_php which occasionally expands beyond the maximum allowed memory usage (ie, the memory_limit definition in in php.ini).
Handling this request calls proc_open() to run external commands. Is the memory usage of those commands counted "against" the requests memory usage?
Beyond that, what are the preferred ways to analyze and fix memory usage of scripts running under mod_php? All the information I've found around php memory usage seems to be:
- "Edit php.ini and raise the memory limit!"
- "Edit your apache config and set max requests per child to a lower number!"
Obviously either of these can have a negative effect on performance and stability. How can I actually analyze and fix the problem, rather than band-aid it?
Apache logs the error as:
PHP Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes) in foo.php on line Z