If you find that you are seeing an out of memory error when running drush commands, you may need to increase the memory limit via a
By default, Drush is configured to use the value set by php.ini, that is, 512 MB of memory on Acquia Cloud for stock php-cli builds. Custom builds of PHP can have a different default. Occasionally, however, you can have scripts, updates, or other commands that require more memory than the default amount.
If a website needs to alter its
DRUSH_PHP setting, it may have a different default (512M) because it does not have a separate
.ini file for the command-line usage. To determine your environment's default memory settings for your PHP build, run the following
php -r 'print ini_get("memory_limit") . "\n";'
One method to increase Drush's memory limit is to create a custom
drushrc.php file to run by using the
--config flag when initiating a Drush command. To do this, complete the following steps:
- Open a command prompt window. For Drupal 7, navigate to
drushand the Drush major version number (for example,
drush6). For Drupal 8, navigate to
/usr/local/[drush_ver]/vendor/drush/drush/examples.Or consider using
- From the
examplesdirectory, copy the
example.drushrc.phpfile and add it to your repository on the same level as docroot in a directory called
- Rename the copied file to
- Add the following line of code to the file to expand the memory limit for Drush (if it's not already set to
This increases the Drush memory limit. You can put your new file into your home
~/.drush directory, which is an easy method.
Alternately, you can commit the new file and directory to allow it to be accessible by Drush commands remotely.
For example if your docroot is
mysite, create a directory called
drush in the root of the repository and the file would be placed in that directory. For example:
After this is done, and you sign in to your Acquia Cloud server using SSH, you can run Drush, adding the
--config flag to use this new memory limit (and any other future
drush configs that may be desirable):
drush --config=/var/www/html/mysite.dev/drush/drushrc.php --root=/var/www/html/mysite.dev/docroot status
This tells Drush to look in the requisite directory for any resource (rc) configuration files and to call them.
For other information on conditionally increasing memory limits, see the article Conditionally increasing memory limits.
For other examples of items you can add to
drushrc.php see example drush aliases .