From a9dc606b8515b6b25b9c76cb0b45e7321d4c6fe4 Mon Sep 17 00:00:00 2001 From: dzzz2001 Date: Thu, 10 Jul 2025 22:13:28 +0800 Subject: [PATCH 1/2] fix memory leak --- source/source_lcao/module_hcontainer/hcontainer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/source_lcao/module_hcontainer/hcontainer.cpp b/source/source_lcao/module_hcontainer/hcontainer.cpp index 3b65203d8a..9571fe40c8 100644 --- a/source/source_lcao/module_hcontainer/hcontainer.cpp +++ b/source/source_lcao/module_hcontainer/hcontainer.cpp @@ -46,6 +46,7 @@ HContainer::HContainer(HContainer&& HR_in) noexcept this->wrapper_pointer = HR_in.wrapper_pointer; this->gamma_only = HR_in.gamma_only; this->paraV = HR_in.paraV; + this->allocated = HR_in.allocated; this->current_R = -1; HR_in.wrapper_pointer = nullptr; // tmp terms not moved @@ -63,6 +64,7 @@ HContainer& HContainer::operator=(HContainer&& HR_in) noexcept this->wrapper_pointer = HR_in.wrapper_pointer; this->gamma_only = HR_in.gamma_only; this->paraV = HR_in.paraV; + this->allocated = HR_in.allocated; this->current_R = -1; HR_in.wrapper_pointer = nullptr; From f68acad807dc4ba30ccab060c8b0b3d7494849a4 Mon Sep 17 00:00:00 2001 From: dzzz2001 Date: Thu, 10 Jul 2025 23:24:43 +0800 Subject: [PATCH 2/2] delete copy assignment --- source/source_lcao/module_hcontainer/hcontainer.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/source_lcao/module_hcontainer/hcontainer.h b/source/source_lcao/module_hcontainer/hcontainer.h index eddfe5db6b..7592273fdb 100644 --- a/source/source_lcao/module_hcontainer/hcontainer.h +++ b/source/source_lcao/module_hcontainer/hcontainer.h @@ -154,7 +154,10 @@ class HContainer * data of HR_in will not be copied, please call add() after this constructor to copy data. */ HContainer(const HContainer& HR_in, T* data_array = nullptr); - + + // copy assignment, not allowed + HContainer& operator=(const HContainer& HR_in) = delete; + // move constructor HContainer(HContainer&& HR_in) noexcept; // move assignment