Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

Tmp.moveFrom(*this); about 10 lines above leaves *this in a zombie
state with a bucket array still allocated. This patch fixes the
memory leak by calling deallocateBuckets().

Tmp.moveFrom(*this); about 10 lines above leaves *this in a zombie
state with a bucket array still allocated.  This patch fixes the
memory leak by calling deallocateBuckets().
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

Tmp.moveFrom(*this); about 10 lines above leaves *this in a zombie
state with a bucket array still allocated. This patch fixes the
memory leak by calling deallocateBuckets().


Full diff: https://github.com/llvm/llvm-project/pull/168011.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/DenseMap.h (+1)
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 9d61a91631fab..333bbcb9399ce 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -1122,6 +1122,7 @@ class SmallDenseMap
       Tmp.Small = false;
       Tmp.getLargeRep()->NumBuckets = 0;
     } else {
+      deallocateBuckets();
       Small = false;
       NumTombstones = 0;
       *getLargeRep() = std::move(*Tmp.getLargeRep());

@kazutakahirata kazutakahirata merged commit afbbd54 into llvm:main Nov 14, 2025
11 of 12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251113_ADT_DenseMap_SmallDenseMap_grow_leak branch November 14, 2025 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants