fix memory leak for fix_dynamic(a.k.a. neigh/history)

This commit is contained in:
cjknight
2024-05-30 14:34:15 -05:00
parent bdbfa7f6e2
commit b5f8d4b46c
4 changed files with 14 additions and 6 deletions

View File

@ -75,6 +75,7 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp)
maxexchange = maxexchange_atom = maxexchange_fix = 0;
maxexchange_fix_dynamic = 0;
bufextra = BUFEXTRA;
bufextra_max = bufextra;
grid2proc = nullptr;
xsplit = ysplit = zsplit = nullptr;

View File

@ -140,6 +140,7 @@ class Comm : protected Pointers {
int maxexchange_fix; // static contribution to maxexchange from Fixes
int maxexchange_fix_dynamic; // 1 if a fix has a dynamic contribution
int bufextra; // augment send buf size for an exchange atom
int bufextra_max;
int gridflag; // option for creating 3d grid
int mapflag; // option for mapping procs to 3d grid

View File

@ -133,9 +133,11 @@ void CommBrick::init()
{
Comm::init();
int bufextra_old = bufextra;
init_exchange();
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2);
if (bufextra > bufextra_max) {
grow_send(maxsend+bufextra,2);
bufextra_max = bufextra;
}
// memory for multi style communication
// allocate in setup
@ -672,9 +674,11 @@ void CommBrick::exchange()
// only need to reset if a fix can dynamically add to size of single atom
if (maxexchange_fix_dynamic) {
int bufextra_old = bufextra;
init_exchange();
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2);
if (bufextra > bufextra_max) {
grow_send(maxsend+bufextra,2);
bufextra_max = bufextra;
}
}
// subbox bounds for orthogonal or triclinic

View File

@ -943,9 +943,11 @@ void CommTiled::exchange()
// only need to reset if a fix can dynamically add to size of single atom
if (maxexchange_fix_dynamic) {
int bufextra_old = bufextra;
init_exchange();
if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2);
if (bufextra > bufextra_max) {
grow_send(maxsend+bufextra,2);
bufextra = bufextra_max;
}
}
// domain properties used in exchange method and methods it calls