diff --git a/folly/memory/Arena.h b/folly/memory/Arena.h index 31518068904..412b5f5277b 100644 --- a/folly/memory/Arena.h +++ b/folly/memory/Arena.h @@ -200,6 +200,7 @@ class Arena { void freeLargeBlocks() { largeBlocks_.clear_and_dispose([this](LargeBlock* b) { auto size = b->allocSize; + totalAllocatedSize_ -= size; b->~LargeBlock(); AllocTraits::deallocate(alloc(), reinterpret_cast(b), size); }); diff --git a/folly/memory/test/ArenaTest.cpp b/folly/memory/test/ArenaTest.cpp index 9b1e74196c5..ca2a5b27878 100644 --- a/folly/memory/test/ArenaTest.cpp +++ b/folly/memory/test/ArenaTest.cpp @@ -216,7 +216,7 @@ TEST(Arena, Clear) { } EXPECT_EQ(arena.bytesUsed(), bytesUsed); - EXPECT_GT(arena.totalSize(), totalSize); + EXPECT_EQ(arena.totalSize(), totalSize); arena.clear(); }