branch-2.1: [fix](mow) fix potential mem leak for DeleteBitmap::AggCache #52596 (#52613)

Cherry-picked from #52596

Co-authored-by: zhannngchen <zhangchen@selectdb.com>
This commit is contained in:
github-actions[bot]
2025-07-02 09:20:30 +08:00
committed by GitHub
parent dc8102bbf4
commit 577ef510d8

View File

@ -536,6 +536,12 @@ public:
std::call_once(once, [size_in_bytes] {
auto* tmp = new AggCachePolicy(size_in_bytes);
AggCache::s_repr.store(tmp, std::memory_order_release);
// release the sigleton instance at program exit
std::atexit([] {
auto* ptr = AggCache::s_repr.exchange(nullptr, std::memory_order_acquire);
delete ptr;
});
});
while (!s_repr.load(std::memory_order_acquire)) {