Unverified Commit 516a3179 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

need to move destruction of base per-atom properties back to atom.cpp so we...

need to move destruction of base per-atom properties back to atom.cpp so we don't leak memory in read_restart and don't crash with replicate
parent ae0957bd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -243,6 +243,14 @@ Atom::~Atom()
  memory->destroy(next);
  memory->destroy(permute);

  memory->destroy(tag);
  memory->destroy(type);
  memory->destroy(mask);
  memory->destroy(image);
  memory->destroy(x);
  memory->destroy(v);
  memory->destroy(f);

  // delete peratom data struct

  for (int i = 0; i < nperatom; i++)
+43 −54
Original line number Diff line number Diff line
@@ -33,8 +33,6 @@ using namespace MathConst;
#define DELTA 16384
#define DELTA_BONUS 8192

int AtomVec::num_atom_vecs = 0;

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

AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp)
@@ -52,11 +50,14 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp)
  kokkosable = 0;

  nargcopy = 0;
  argcopy = NULL;
  argcopy = nullptr;

  threads = NULL;
  tag = nullptr;
  type = mask = nullptr;
  image = nullptr;
  x = v = f = nullptr;

  ++num_atom_vecs;
  threads = nullptr;

  // peratom variables auto-included in corresponding child style fields string
  // these fields cannot be specified in the fields string
@@ -97,20 +98,9 @@ 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);
    memory->destroy(atom->image);
    memory->destroy(atom->x);
    memory->destroy(atom->v);
    memory->destroy(atom->f);

  for (int i = 0; i < ngrow; i++) {
    pdata = mgrow.pdata[i];
    datatype = mgrow.datatype[i];
@@ -141,7 +131,6 @@ AtomVec::~AtomVec()
      }
    }
  }
  }

  destroy_method(&mgrow);
  destroy_method(&mcopy);
@@ -194,7 +183,7 @@ void AtomVec::init()
  deform_groupbit = domain->deform_groupbit;
  h_rate = domain->h_rate;

  if (lmp->kokkos != NULL && !kokkosable)
  if (lmp->kokkos != nullptr && !kokkosable)
    error->all(FLERR,"KOKKOS package requires a kokkos enabled atom_style");
}

@@ -2492,8 +2481,8 @@ void AtomVec::setup_fields()

int AtomVec::process_fields(char *str, const char *default_str, Method *method)
{
  if (str == NULL) {
    method->index = NULL;
  if (str == nullptr) {
    method->index = nullptr;
    return 0;
  }

@@ -2572,13 +2561,13 @@ void AtomVec::create_method(int nfield, Method *method)

void AtomVec::init_method(Method *method)
{
  method->pdata = NULL;
  method->datatype = NULL;
  method->cols = NULL;
  method->maxcols = NULL;
  method->collength = NULL;
  method->plength = NULL;
  method->index = NULL;
  method->pdata = nullptr;
  method->datatype = nullptr;
  method->cols = nullptr;
  method->maxcols = nullptr;
  method->collength = nullptr;
  method->plength = nullptr;
  method->index = nullptr;
}

/* ----------------------------------------------------------------------
+0 −4
Original line number Diff line number Diff line
@@ -209,10 +209,6 @@ class AtomVec : protected Pointers {

  bool *threads;

  // counter for atom vec instances

  static int num_atom_vecs;

  // local methods

  void grow_nmax();