I've got a drush script that's used to clear out old, unpublished nodes that have come in from feedapi. The script is fairly simple: get all the nodes with status 0 of a certain type ("post") and age (older than 90 days), loop through them, delete each one.
The script runs through about 4,000 nodes at a time, then exhausts the memory available to its PHP process. I can watch the script's footprint grow from
top and the 4,000 node limit is somewhat consistent. I've got over 100,000 nodes to work through, though, so I don't think it will be practical to just jack up the RAM available to the process long enough to get a run out of it.
Is there anything I can add at the bottom of each iteration to release the RAM it's consuming?