Skip to content
Snippets Groups Projects
Commit 1b07a4ed authored by Richard Berger's avatar Richard Berger
Browse files

Fix memory leak in pair python

parent 81a1c007
No related branches found
No related tags found
No related merge requests found
...@@ -181,6 +181,7 @@ void PairPython::compute(int eflag, int vflag) ...@@ -181,6 +181,7 @@ void PairPython::compute(int eflag, int vflag)
error->all(FLERR,"Calling 'compute_force' function failed"); error->all(FLERR,"Calling 'compute_force' function failed");
} }
fpair = factor_lj*PyFloat_AsDouble(py_value); fpair = factor_lj*PyFloat_AsDouble(py_value);
Py_DECREF(py_value);
f[i][0] += delx*fpair; f[i][0] += delx*fpair;
f[i][1] += dely*fpair; f[i][1] += dely*fpair;
...@@ -194,6 +195,7 @@ void PairPython::compute(int eflag, int vflag) ...@@ -194,6 +195,7 @@ void PairPython::compute(int eflag, int vflag)
if (eflag) { if (eflag) {
py_value = PyObject_CallObject(py_compute_energy,py_compute_args); py_value = PyObject_CallObject(py_compute_energy,py_compute_args);
evdwl = factor_lj*PyFloat_AsDouble(py_value); evdwl = factor_lj*PyFloat_AsDouble(py_value);
Py_DECREF(py_value);
} else evdwl = 0.0; } else evdwl = 0.0;
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,
...@@ -467,6 +469,7 @@ double PairPython::single(int i, int j, int itype, int jtype, double rsq, ...@@ -467,6 +469,7 @@ double PairPython::single(int i, int j, int itype, int jtype, double rsq,
error->all(FLERR,"Calling 'compute_force' function failed"); error->all(FLERR,"Calling 'compute_force' function failed");
} }
fforce = factor_lj*PyFloat_AsDouble(py_value); fforce = factor_lj*PyFloat_AsDouble(py_value);
Py_DECREF(py_value);
py_value = PyObject_CallObject(py_compute_energy,py_compute_args); py_value = PyObject_CallObject(py_compute_energy,py_compute_args);
if (!py_value) { if (!py_value) {
...@@ -476,6 +479,7 @@ double PairPython::single(int i, int j, int itype, int jtype, double rsq, ...@@ -476,6 +479,7 @@ double PairPython::single(int i, int j, int itype, int jtype, double rsq,
error->all(FLERR,"Calling 'compute_energy' function failed"); error->all(FLERR,"Calling 'compute_energy' function failed");
} }
double evdwl = factor_lj*PyFloat_AsDouble(py_value); double evdwl = factor_lj*PyFloat_AsDouble(py_value);
Py_DECREF(py_value);
Py_DECREF(py_compute_args); Py_DECREF(py_compute_args);
PyGILState_Release(gstate); PyGILState_Release(gstate);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment