fixed memory leaks from unit-test LogDetEstimator.Sparse_sample #1989

fixed memory leaks. solves #1989