From 439ee78c7c3aa2bea6f407d580ee79bfc7f8e203 Mon Sep 17 00:00:00 2001 From: Ian Hammond Date: Wed, 8 Feb 2023 22:13:07 -0500 Subject: [PATCH] memory leak fix; Py_XDCREF amp_func set to NULL --- python/meep.i | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/meep.i b/python/meep.i index 78f922919..2a9da2bd8 100644 --- a/python/meep.i +++ b/python/meep.i @@ -714,6 +714,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c, %typemap(freearg) double (*)(const meep::vec &) { Py_XDECREF(py_callback); + py_callback = NULL; } %typecheck(SWIG_TYPECHECK_POINTER) double (*)(const meep::vec &) { @@ -738,6 +739,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c, %typemap(freearg) std::complex (*)(const meep::vec &) { Py_XDECREF(py_amp_func); + py_amp_func = NULL; } // Typemap suite for vector3 @@ -1050,6 +1052,7 @@ void _get_gradient(PyObject *grad, double scalegrad, %typemap(freearg) std::complex (*)(const meep::vec &) { Py_XDECREF(py_amp_func); + py_amp_func = NULL; } %typecheck(SWIG_TYPECHECK_POINTER) PyObject *min_max_loc {