Catch exceptions when large allocations fail
Merge pull request #776 from virtuald:2.4