PHP Fatal error: Allowed memory size of 262144 bytes exhausted

PHP Fatal error:  Allowed memory size of 262144 bytes exhausted

I just ran across this issue and it threw me for a loop for several hours so I thought I would share the solution here. In my case I was attempting to reindex a Magento database via php cli on the command line, however this issue is not Magento specific. For those Magento folks out there here is the command line along with the full error message. 

Command: php indexer.php --reindexall

Error:

PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 90 bytes) in /var/www/html/gearhead.com/app/code/core/Mage/Index/Model/Process.php on line 441 

Pretty straight forward error message. I only have 262k of memory available for php to do it's business which is not enough to run the script. I check my memory_limit with "php -i | grep memory_limit" and see that it's set at 512M. Clearly the command line client is not using my php.ini memory_limit.

In most cases this error is fixed by simply adjusting the memory_limit however we have a mismatch between what php cli is using and what our php.ini is configured for. On a side note I found several forums indicating the possibility of two php.ini files, one for the web server and one for the command line client. I only have one php.ini but be sure to run "php -i  | grep php.ini" to make sure you're editing the right one if you need to make changes to php.ini for the command line client.

Issue:

This error is caused by the presence of a .htaccess file which defines "php_value memory_limit 512M". Your amount may not be 512M but you get the point.

Solution: 

Comment out "php_value memory_limit 512M" in your .htaccess file.

 

Comments


Boise Web Design

Established in the City of Trees in Boise Idaho in 2002, Vector Network Solutions is now a leading web development company providing Boise web design with over ten years of experience. Leading the way with a proven track record on the industries top web platforms, VectorNS is capable of delivering exceptional solutions to clients around the globe. Our strategic methods afford us the ability to provide Boise with web design, development and a sharp competitive edge. Call or e-mail today to start initiating your project with the experienced professionals at VectorNS.

Free Web Tips & Ideas!

Sign up for VectorNS Web Tips and recieve occasional tips & ideas to enhance your web presence.