From cc716ef16b15f0221fccfc1798ee5cd38fa8d418 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 3 Jul 2024 09:48:02 -0700 Subject: [PATCH] Attempt to fix memory leak --- ConflictSet.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 4ab790b..1618193 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -606,6 +606,14 @@ template struct BoundedFreeListAllocator { VALGRIND_MAKE_MEM_NOACCESS(freeList, sizeof(T) + p->partialKeyCapacity); } + BoundedFreeListAllocator() = default; + + BoundedFreeListAllocator(const BoundedFreeListAllocator &) = delete; + BoundedFreeListAllocator & + operator=(const BoundedFreeListAllocator &) = delete; + BoundedFreeListAllocator(BoundedFreeListAllocator &&) = delete; + BoundedFreeListAllocator &operator=(BoundedFreeListAllocator &&) = delete; + ~BoundedFreeListAllocator() { for (void *iter = freeList; iter != nullptr;) { VALGRIND_MAKE_MEM_DEFINED(iter, sizeof(Node)); @@ -2994,7 +3002,8 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { oldestVersionFullPrecision = oldestExtantVersion = oldestVersionAtGcBegin = newestVersionFullPrecision = oldestVersion; - allocators = {}; + allocators.~NodeAllocators(); + new (&allocators) NodeAllocators(); removalKeyArena = Arena{}; removalKey = {};