Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

for some reason, my one of my php scripts are ignoring the php.ini memory limit or ini_set.

When i do a print_r(ini_get_all) it shows the global memory limit set to 100M (and local for that matter), when my script dies at Fatal error: Out of memory (allocated 24714304) (tried to allocate 571 bytes)

Any tips on diagnosing this? The server has 8gigs of memory and never had problems running this script before.

Any tips on debugging this?

Thanks!

like image 240
james Avatar asked Dec 30 '09 20:12

james


1 Answers

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.

like image 197
zombat Avatar answered Oct 11 '22 06:10

zombat