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?
free
is all physical memory. Also, you are wrong about half the memory being used to run the GUI. The memory is used largely for buffers and cache. The system simply hasn't bothered to make it free because it already has sufficient free memory, so it would be wasted effort.php.ini
file (check something like/etc/php5/cli
) and are editing the wrong one or you have aini_set('memory_limit', '512M');
setting in asettings.php
file or the like that is getting included.