Be a bit more robust in the face of out-of-memory errors.