I have a PHP script that while a folder contains XML files, it will process them onto the database.
Currently, the server is running the PHP version 5.3.10 and there's a bug report about memory issues triggered by
ZEND_MM_HEAP within a loop.
This causes the PHP to not free memory properly, thus leading to an error and a script crash:
zend_mm_heap is corrupted
Some solutions are found, but I don't have access to the server settings.
To deal with this, I've prepared the following bash to take care of the loop, leaving the PHP script only responsible by processing the XML file:
#!/bin/bash # Check for files to process # If files are present, call # the PHP script DIR="/path/to/dir/with/files" while [ "$(ls -A $DIR)" ]; do php /path/to/php/script/myscript.php done
My goal now is to have this bash memory allocation limited (memory and virtual memory), thus preventing it to hang the system if something goes wrong.
My Question is:
How can I limit the memory used by this shell script to a specific amount?