Drush command to delete content going out of memeory. What can I do?
If you look at the code for node_delete_multiple() it does a node_load_multiple().  While this seems strange, it has to do this so that it can invoke all of the proper hooks so that other modules have the full $node object in order to do their thing (eg, delete the attached field data).

Because Drupal uses aggressive static caching to avoid redundant database accesses, memory usage can swell.  This can't be freed or disabled.  If this becomes an issue, you can do temp edits to the EntityControllers to comment out the static caches.  You could also make a temp edit to drupal_static() to effectively disable it.

I would come up with a good EntityFieldQuery to get the list of nodes to delete.  This will just give you back the nids.

Suck out the nids, and trim the array to some limit.

Call node_delete_multiple() on the result.

$query = new EntityFieldQuery();
$entities = $query-&gt;entityCondition('entity_type', 'node', '=')
  -&gt;entityCondition('bundle', $bundle)
  -&gt;addCondition(...)
  -&gt;execute();

$nids = array_slice($entities['node'], 0, 1000);

print 'Deleting ' . count($nids) . ' nodes ... ';

if (!empty($nids)) {
  node_delete_multiple($nids);
}

print "done\n";


Put this in a standalone PHP and execute is from drush, eg

drush -u 1 scr nuke_everything.php


Run it until everything is gone.

The above solution is for Drupal 7, but the approach is essentially the same for Drupal 6.  You would do a db_query() to get the nids, and then loop through and call node_delete() on each.  However, Drupal 6 also does a full node_load(), too.  In this instance, it does bypass its static cache, but this doesn't mean that modules aren't also doing any static caching.  For Drupal 6, you would need to chase all of the possible hook_nodeapi('delete') and look for static caching and static caching in any functions that get called, and do temp edits.