Unverified Commit 5291a461 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #2180 from akohlmey/atomvec-deallocate-fix

Deallocate per-atom data less aggressively so replicate command keeps working
parents 3fffe204 19825876
Loading
Loading
Loading
Loading
+43 −35
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ using namespace MathConst;
#define DELTA 16384
#define DELTA_BONUS 8192

int AtomVec::num_atom_vecs = 0;

/* ---------------------------------------------------------------------- */

AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp)
@@ -54,6 +56,8 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp)

  threads = NULL;

  ++num_atom_vecs;

  // peratom variables auto-included in corresponding child style fields string
  // these fields cannot be specified in the fields string

@@ -93,9 +97,12 @@ AtomVec::~AtomVec()
  int datatype,cols;
  void *pdata;

  --num_atom_vecs;

  for (int i = 0; i < nargcopy; i++) delete [] argcopy[i];
  delete [] argcopy;

  if (num_atom_vecs == 0) {
    memory->destroy(atom->tag);
    memory->destroy(atom->type);
    memory->destroy(atom->mask);
@@ -134,6 +141,7 @@ AtomVec::~AtomVec()
        }
      }
    }
  }

  destroy_method(&mgrow);
  destroy_method(&mcopy);
+4 −0
Original line number Diff line number Diff line
@@ -209,6 +209,10 @@ class AtomVec : protected Pointers {

  bool *threads;

  // counter for atom vec instances

  static int num_atom_vecs;

  // local methods

  void grow_nmax();