Commit 78fe8913 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

fix Arena total-size accounting across clear

Summary: Fix `Arena` total-size accounting across calls to `clear`, as reported by member `totalSize`.

Reviewed By: luciang

Differential Revision: D25656867

fbshipit-source-id: b5c7bb0e95199a9fa2c94c04de65b8f494eef146
parent 2d871f2f
......@@ -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<char*>(b), size);
});
......
......@@ -216,7 +216,7 @@ TEST(Arena, Clear) {
}
EXPECT_EQ(arena.bytesUsed(), bytesUsed);
EXPECT_GT(arena.totalSize(), totalSize);
EXPECT_EQ(arena.totalSize(), totalSize);
arena.clear();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment