Drush PHP memory limit

With the default PHP settings, Drush will probably get a fatal error because the PHP memory limit is too low. Thankfully, the solution is very simple.

The Problem

You are using Drush and you get the following fatal error:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to 
allocate 30720 bytes) in
/var/www/path/to/site/sites/all/modules/modulename/modulename.module 
on line 1271

The Solution

The solution is pretty straight forward. You need to increase the memory limit in the CLI version of php.ini. You may have already increased the memory limit in the Apache2 version but forgotten about the CLI version.

Assuming you are running Linux, Mac OSX or similar, open the php.ini in nano (or your preferred editor):

sudo nano /etc/php5/cli/php.ini

Search for memory_limit. By default, this will be set to 32MB. Increase this to 256MB and save and close the file.

That is it!

Post new comment

The content of this field is kept private and will not be shown publicly.

Learn how to write custom Drupal modules

Does Drupal module development make your head explode and drive you crazy?

Why not learn from someone who has paved the way instead?

Sign up to Master Drupal 7 Module Development.

Hello!!

I am Blair Wadman and this is where I write about Drupal, PHP, CSS etc

Stuff

Syndicate

Syndicate content

© Blair Wadman
2005 - 2011