For a project at Intracto digital agency, we are doing daily imports and updates using the fantastic Drupal Migrate framework.

Lately we ran into an issue where our daily migrate updates ran out of memory.   We are running our migrate classes over drush using a cronjob.
Drupal Migrate should handle memory for you, so why was it failing on us?


The fix?

We are running php in cli (command line interface) over unlimited memory using a bash script.
Putting a cap on our cli php memory suddenly ensures migrate is managing memory (and respawning a new process when necessary) for us.

Detailed bash-script example for debian-based users:

# Ensure PHP over cli has a memory limit when running Drupal Migrate
# else Drupal Migrate wont be able to respawn a new process!
# See:
# Tweakable stuff
# Run Drupal Migrate imports
php -dmemory_limit=${php_memory_limit} ${drush_path}drush.php mi YourMigrateClass --feedback="1000 items" --root=${drupal_path}


Happy migrating!


Update: Thanks @tvlooy for suggesting to set memory limit at runtime instead of using php.ini

Add new comment