Skip to content

Commit

Permalink
fix Arena total-size accounting across clear
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Dec 21, 2020
1 parent 2d871f2 commit 78fe891
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions folly/memory/Arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion folly/memory/test/ArenaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ TEST(Arena, Clear) {
}

EXPECT_EQ(arena.bytesUsed(), bytesUsed);
EXPECT_GT(arena.totalSize(), totalSize);
EXPECT_EQ(arena.totalSize(), totalSize);

arena.clear();
}
Expand Down

0 comments on commit 78fe891

Please sign in to comment.