I am facing the common "Fatal error: Out of memory (allocated 30408704) (tried to allocate 24 bytes)..." PHP Fatal error. Pages served via Apache are not exhibiting this behavior.
I've tried the following:
ini_set('memory_limit', -1)
, ini_set('memory_limit', '-1')
, ini_set('memory_limit', 100000000)
, ini_set('memory_limit', '128M')
, etc.unset()
ing unneeded arrays and objects to encourage the garbage collector to free up memory.-c
command-line flag to hand-pick specific php.ini files with various values.Regardless of what I try, the error message is the same. It appears that my command line scripts are ignoring changes to memory_limit
.
I tend to try to make sure my scripts are memory efficient, but I'm currently needing to parse large amounts of HTML via Simple HTML DOM and it is in the parser that I'm experiencing out of memory issues. In an attempt to reduce the memory footprint of the script, I've tried using DOMDocument instead. This does not help either. In fact, the out of memory error is now triggered elsewhere in the script.
My question: has anyone experienced this or a similar issue? Do you have any recommendations?
Thank you.
It turns out that the problem was caused by shell fork bomb protection being enabled on the server that was placing a hard memory limit on all command-line scripts. This had been enabled by my web host without my knowledge.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With