From a1e876a7d6a6baa1bda151b548ca78662301c4b3 Mon Sep 17 00:00:00 2001 From: "clemens.schmid@esrf.fr" Date: Thu, 18 Jun 2026 16:13:10 +0200 Subject: [PATCH 1/3] Return pyarray directly instead of bp::incref to avoid memory ballooning --- src/extensions/registerconverters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/registerconverters.cpp b/src/extensions/registerconverters.cpp index e421487..bac7484 100644 --- a/src/extensions/registerconverters.cpp +++ b/src/extensions/registerconverters.cpp @@ -61,7 +61,7 @@ PyObject* makeNdArray(const double* data, std::vector& dims) PyArrayObject* a = reinterpret_cast(pyarray); double* adata = static_cast(PyArray_DATA(a)); std::copy(data, data + PyArray_SIZE(a), adata); - return bp::incref(pyarray); + return pyarray; } // CrystVector to ndarray From a7d3e1e6c667114a7d9d06ff835e287d75c9cf28 Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Tue, 25 Aug 2026 13:57:24 +0200 Subject: [PATCH 2/3] add news file --- news/fix_pyarray_ref.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/fix_pyarray_ref.rst diff --git a/news/fix_pyarray_ref.rst b/news/fix_pyarray_ref.rst new file mode 100644 index 0000000..234489b --- /dev/null +++ b/news/fix_pyarray_ref.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Fix memory leak in makeNdArray + +**Security:** + +* From 89bfc04be4fd0f2a86741f1e3df3f4f237732621 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2026 11:57:42 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit hooks --- news/fix_pyarray_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/fix_pyarray_ref.rst b/news/fix_pyarray_ref.rst index 234489b..4f2b7ca 100644 --- a/news/fix_pyarray_ref.rst +++ b/news/fix_pyarray_ref.rst @@ -16,7 +16,7 @@ **Fixed:** -* Fix memory leak in makeNdArray +* Fix memory leak in makeNdArray **Security:**