Php CLI script ignoring memory_limit, crashing at much lower number than limit

The single most common cause of this is that usually the CLI PHP binary is using a different php.ini file than you expect. This can be caused by user permissions, or simply different default php.ini files for installed versions of PHP. However, it sounds like you've profiled it a bit and your memory limit may be correct inside your script.

In that case, it's quite possible that there is a hard memory limit on processes that is imposed by your operating system, in which case you'll have to figure out where the imposition comes from.

I suggest taking a look at this thread, as that poster went through something very similar to your situation.


The virtual memory for my processes was being hard limited (too a much lower number).

From a bash shell i did this:

ulimit -v (memory_in_bytes, no parentheses)

this fixed my problem. god i love stackoverflow