Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
You're confusing virtual memory limits with physical memory limits. The PHP memory limit is a virtual memory limit. The output of 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. –  David Schwartz Nov 15 '12 at 23:58
1  
Most likely, you have more than one php.ini file (check something like /etc/php5/cli) and are editing the wrong one or you have a ini_set('memory_limit', '512M'); setting in a settings.php file or the like that is getting included. –  David Schwartz Nov 16 '12 at 0:00
    
@David - I had an extra ini_set() in the coedbase hanging around from troubleshooting code. IF you post that answer I will upvote and accept it. –  user13743 Nov 16 '12 at 14:37
add comment

2 Answers 2

up vote 2 down vote accepted

Most likely, you have more than one php.ini file (check something like /etc/php5/cli) and are editing the wrong one or you have a ini_set('memory_limit', '512M'); setting in a settings.php file or the like that is getting included.

share|improve this answer
add comment

in Mac for instance

/etc/php5/cli is for command line, so you need to change /etc/php5/cgi/php.ini

that should work !

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.