Fix memory leak

This commit is contained in:
Stan Gerald Moore
2024-02-27 14:50:20 -07:00
parent 7593f0df22
commit 4dbfa5483b
2 changed files with 6 additions and 3 deletions

View File

@ -36,6 +36,7 @@ static constexpr int BUFEXTRA = 1000;
CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp)
{
sendlist = nullptr;
}
/* ---------------------------------------------------------------------- */
@ -47,6 +48,7 @@ CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp)
CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp, Comm *oldcomm) : CommTiled(_lmp,oldcomm)
{
sendlist = nullptr;
}
/* ---------------------------------------------------------------------- */
@ -57,7 +59,6 @@ CommTiledKokkos::~CommTiledKokkos()
sendlist = nullptr;
buf_send = nullptr;
buf_recv = nullptr;
maxswap = 0;
}
/* ---------------------------------------------------------------------- */

View File

@ -2468,8 +2468,10 @@ void CommTiled::deallocate_swap(int n)
delete [] maxsendlist[i];
for (int j = 0; j < nprocmax[i]; j++) memory->destroy(sendlist[i][j]);
delete [] sendlist[i];
if (sendlist && sendlist[i]) {
for (int j = 0; j < nprocmax[i]; j++) memory->destroy(sendlist[i][j]);
delete [] sendlist[i];
}
}
delete [] sendproc;