From ca8bc5f7e8e46e2455531e669aca0a7239d84cb3 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 1 Aug 2023 14:13:05 -0700 Subject: [PATCH 1/2] free helper ops --- src/sunmemory/cuda/sundials_cuda_memory.cu | 3 ++- src/sunmemory/hip/sundials_hip_memory.hip.cpp | 3 ++- src/sunmemory/sycl/sundials_sycl_memory.cpp | 3 ++- src/sunmemory/system/sundials_system_memory.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sunmemory/cuda/sundials_cuda_memory.cu b/src/sunmemory/cuda/sundials_cuda_memory.cu index 8716d1dd72..f0b7bab145 100644 --- a/src/sunmemory/cuda/sundials_cuda_memory.cu +++ b/src/sunmemory/cuda/sundials_cuda_memory.cu @@ -341,7 +341,8 @@ int SUNMemoryHelper_Destroy_Cuda(SUNMemoryHelper helper) { if (helper) { - free(helper->content); + if (helper->content) { free(helper->content); } + if (helper->ops) { free(helper->ops); } free(helper); } return 0; diff --git a/src/sunmemory/hip/sundials_hip_memory.hip.cpp b/src/sunmemory/hip/sundials_hip_memory.hip.cpp index 6c7cae919a..c862fd4f88 100644 --- a/src/sunmemory/hip/sundials_hip_memory.hip.cpp +++ b/src/sunmemory/hip/sundials_hip_memory.hip.cpp @@ -340,7 +340,8 @@ int SUNMemoryHelper_Destroy_Hip(SUNMemoryHelper helper) { if (helper) { - free(helper->content); + if (helper->content) { free(helper->content); } + if (helper->ops) { free(helper->ops); } free(helper); } return 0; diff --git a/src/sunmemory/sycl/sundials_sycl_memory.cpp b/src/sunmemory/sycl/sundials_sycl_memory.cpp index 6156ecdacb..c14ced9dfd 100644 --- a/src/sunmemory/sycl/sundials_sycl_memory.cpp +++ b/src/sunmemory/sycl/sundials_sycl_memory.cpp @@ -304,7 +304,8 @@ int SUNMemoryHelper_Destroy_Sycl(SUNMemoryHelper helper) { if (helper) { - free(helper->content); + if (helper->content) { free(helper->content); } + if (helper->ops) { free(helper->ops); } free(helper); } return 0; diff --git a/src/sunmemory/system/sundials_system_memory.c b/src/sunmemory/system/sundials_system_memory.c index 088f06d8d9..2987c45289 100644 --- a/src/sunmemory/system/sundials_system_memory.c +++ b/src/sunmemory/system/sundials_system_memory.c @@ -160,7 +160,8 @@ int SUNMemoryHelper_Destroy_Sys(SUNMemoryHelper helper) { if (helper) { - free(helper->content); + if (helper->content) { free(helper->content); } + if (helper->ops) { free(helper->ops); } free(helper); } return 0; From 6cd6237bf9601c3458a0300188f6cba567e97212 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 1 Aug 2023 14:16:55 -0700 Subject: [PATCH 2/2] update recent changes --- CHANGELOG.md | 5 +++++ doc/arkode/guide/source/Introduction.rst | 6 ++++++ doc/cvode/guide/source/Introduction.rst | 6 ++++++ doc/cvodes/guide/source/Introduction.rst | 6 ++++++ doc/ida/guide/source/Introduction.rst | 6 ++++++ doc/idas/guide/source/Introduction.rst | 6 ++++++ doc/kinsol/guide/source/Introduction.rst | 6 ++++++ 7 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d17ba09be4..5129794504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # SUNDIALS Changelog +## Changes to SUNDIALS in release x.x.x + +Fixed a memory leak when destroying a CUDA, HIP, SYCL, or system SUNMemoryHelper +object. + ## Changes to SUNDIALS in release 6.6.0 A new time-stepping module, `SPRKStep`, was added to ARKODE. This time-stepper diff --git a/doc/arkode/guide/source/Introduction.rst b/doc/arkode/guide/source/Introduction.rst index ad675a5ccc..b532f9243e 100644 --- a/doc/arkode/guide/source/Introduction.rst +++ b/doc/arkode/guide/source/Introduction.rst @@ -130,6 +130,12 @@ provided with SUNDIALS, or again may utilize a user-supplied module. Changes from previous versions ============================== +Changes in vX.X.X +----------------- + +Fixed a memory leak when destroying a CUDA, HIP, SYCL, or system SUNMemoryHelper +object. + Changes in v5.6.0 ----------------- diff --git a/doc/cvode/guide/source/Introduction.rst b/doc/cvode/guide/source/Introduction.rst index ff6741b0bc..98b1aff326 100644 --- a/doc/cvode/guide/source/Introduction.rst +++ b/doc/cvode/guide/source/Introduction.rst @@ -111,6 +111,12 @@ implementations. Changes from previous versions ============================== +Changes in vX.X.X +----------------- + +Fixed a memory leak when destroying a CUDA, HIP, SYCL, or system SUNMemoryHelper +object. + Changes in v6.6.0 ----------------- diff --git a/doc/cvodes/guide/source/Introduction.rst b/doc/cvodes/guide/source/Introduction.rst index a562b42cbc..b634624683 100644 --- a/doc/cvodes/guide/source/Introduction.rst +++ b/doc/cvodes/guide/source/Introduction.rst @@ -111,6 +111,12 @@ Fortran. Changes from previous versions ============================== +Changes in vX.X.X +----------------- + +Fixed a memory leak when destroying a CUDA, HIP, SYCL, or system SUNMemoryHelper +object. + Changes in v6.6.0 ----------------- diff --git a/doc/ida/guide/source/Introduction.rst b/doc/ida/guide/source/Introduction.rst index b2a5a15671..cacbd25aa4 100644 --- a/doc/ida/guide/source/Introduction.rst +++ b/doc/ida/guide/source/Introduction.rst @@ -72,6 +72,12 @@ systems. Changes from previous versions ============================== +Changes in vX.X.X +----------------- + +Fixed a memory leak when destroying a CUDA, HIP, SYCL, or system SUNMemoryHelper +object. + Changes in v6.6.0 ----------------- diff --git a/doc/idas/guide/source/Introduction.rst b/doc/idas/guide/source/Introduction.rst index 67f4afe223..0244e5f494 100644 --- a/doc/idas/guide/source/Introduction.rst +++ b/doc/idas/guide/source/Introduction.rst @@ -86,6 +86,12 @@ integrate any final-condition ODE dependent on the solution of the original IVP Changes from previous versions ============================== +Changes in vX.X.X +----------------- + +Fixed a memory leak when destroying a CUDA, HIP, SYCL, or system SUNMemoryHelper +object. + Changes in v5.6.0 ----------------- diff --git a/doc/kinsol/guide/source/Introduction.rst b/doc/kinsol/guide/source/Introduction.rst index 49916102a2..e55881feca 100644 --- a/doc/kinsol/guide/source/Introduction.rst +++ b/doc/kinsol/guide/source/Introduction.rst @@ -88,6 +88,12 @@ applications written in Fortran. Changes from previous versions ============================== +Changes in vX.X.X +----------------- + +Fixed a memory leak when destroying a CUDA, HIP, SYCL, or system SUNMemoryHelper +object. + Changes in v6.6.0 -----------------