Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in SUNMemoryHelpers #314

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions doc/arkode/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------

Expand Down
6 changes: 6 additions & 0 deletions doc/cvode/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------

Expand Down
6 changes: 6 additions & 0 deletions doc/cvodes/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------

Expand Down
6 changes: 6 additions & 0 deletions doc/ida/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------

Expand Down
6 changes: 6 additions & 0 deletions doc/idas/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------

Expand Down
6 changes: 6 additions & 0 deletions doc/kinsol/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------

Expand Down
3 changes: 2 additions & 1 deletion src/sunmemory/cuda/sundials_cuda_memory.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/sunmemory/hip/sundials_hip_memory.hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/sunmemory/sycl/sundials_sycl_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/sunmemory/system/sundials_system_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down