Catch OOM.
Merge pull request #359 from square/dimitris/oom

Catch OOM.