From adf21835f76a132f5d9ca57827c387eb1bf97549 Mon Sep 17 00:00:00 2001 From: Andrew Wiltshire <62200778+AW1534@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:05:51 +0100 Subject: [PATCH 1/3] Reduce Memory Leaks --- src/core/NotePlayHandle.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index d7882b525d2..a4d443ea858 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -670,7 +670,13 @@ void NotePlayHandleManager::extend( int c ) void NotePlayHandleManager::free() { - delete[] s_available; + if (s_available != nullptr) { + if (s_available[0] != nullptr) { + std::free(s_available[0]); // Free the block of NotePlayHandle objects + } + delete[] s_available; // Then free the array of pointers + s_available = nullptr; + } } From b2eb17a70191461f93f4bc26232f2c6dcb35e4e4 Mon Sep 17 00:00:00 2001 From: Andrew Wiltshire <62200778+AW1534@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:13:56 +0100 Subject: [PATCH 2/3] Reduce Memory Leaks --- src/core/NotePlayHandle.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index a4d443ea858..59ad9fd1fe8 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -670,13 +670,9 @@ void NotePlayHandleManager::extend( int c ) void NotePlayHandleManager::free() { - if (s_available != nullptr) { - if (s_available[0] != nullptr) { - std::free(s_available[0]); // Free the block of NotePlayHandle objects - } - delete[] s_available; // Then free the array of pointers - s_available = nullptr; - } + delete s_available[0]; // Free the block of NotePlayHandle objects + delete[] s_available; // Then free the array of pointers + s_available = nullptr; } From dd7cea19247db786f6a12d7bdb330fd08e23681b Mon Sep 17 00:00:00 2001 From: Andrew Wiltshire <62200778+AW1534@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:14:33 +0100 Subject: [PATCH 3/3] Update NotePlayHandle.cpp --- src/core/NotePlayHandle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 59ad9fd1fe8..39f9876da80 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -670,8 +670,8 @@ void NotePlayHandleManager::extend( int c ) void NotePlayHandleManager::free() { - delete s_available[0]; // Free the block of NotePlayHandle objects - delete[] s_available; // Then free the array of pointers + delete s_available[0]; + delete[] s_available; s_available = nullptr; }