Bad alloc in covariance