PHP CLI not respecting memory limit in php.ini

Posted by user13743 on Super User See other posts from Super User or by user13743
Published on 2012-11-15T22:53:41Z Indexed on 2012/11/15 23:05 UTC
Read the original article Hit count: 803

Filed under:
|
|
|

I am using drush, which is a command-line php app to manage a drupal website. I am running a command to import a lot of data, which is causing me to hit php's memory limit.

PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted ...

Which is 512MB if I'm doing the math correctly (536870912 / 1024 / 1024 = 512). I've changed the directive in the php.ini that drush uses:

$> drush status
  ...
  PHP configuration      :  /etc/php5/cli/php.ini 
$> grep memory /etc/php5/cli/php.ini 
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 1024M 

But I'm still hitting the 512 MB limit! I am running in a virtual machine, whose memory settings I changed from 512 to 1025 MB of RAM to allow drush to run.

$> free -m
             total       used       free     shared    buffers     cached
Mem:          1010        578        431          0         14        392
-/+ buffers/cache:        172        837
Swap:          382          0        382

So it says it has some 431 MB free, now that I've bumped the vm up to 1024. I guess half the memory is being used to run the GUI, but I don't understand how the GUI was running okay when the vm had 512 MB of ram.

Why is the PHP cli still hitting a 512 MB memory limit? If it was hitting a system memory limit, shouldn't it die around 431MB, which is what the free command says is available?

© Super User or respective owner

Related posts about memory

Related posts about php