Throw better exception if allocation failed.