ORNL / ReSolve

Library of GPU-resident linear solvers
Other
58 stars 2 forks source link

Memory leak in `GramSchmidt` class #196

Closed pelesh closed 1 month ago

pelesh commented 2 months ago

In reorthogonalization methods Modified 2-Sync Gramm-Schmidt and Postmodern Gramm_Schmidt, member variable h_rv_ (a pointer to real_type) is first allocated

  h_rv_ = new real_type[num_vecs_ + 1];

and then, a few lines later, a new value is assigned to the pointer h_rv_ as

  h_rv_ = vec_rv_->getVectorData(1, memory::HOST);

thus leaking previous allocation.

There is no need for h_rv_ to be a member variable to begin with, since it is used only locally in Modified 2-sync and Postmodern Gram-Schmidt methods. It should be defined locally in the orthogonalize function and initialized to nullptr.

CC @stonecoldhughes @maksud