Correctly release PoolResource memory
Reviewers: mferencevic, ipaljak Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2341
This commit is contained in:
parent
ed802073f6
commit
32ae2b4d23
@ -256,6 +256,8 @@ void Pool::Release() {
|
|||||||
GetUpstreamResource()->Deallocate(chunk.data, data_size, alignment);
|
GetUpstreamResource()->Deallocate(chunk.data, data_size, alignment);
|
||||||
}
|
}
|
||||||
chunks_.clear();
|
chunks_.clear();
|
||||||
|
last_alloc_chunk_ = nullptr;
|
||||||
|
last_dealloc_chunk_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace impl
|
} // namespace impl
|
||||||
@ -363,6 +365,8 @@ void PoolResource::Release() {
|
|||||||
GetUpstreamResource()->Deallocate(big_block.data, big_block.bytes,
|
GetUpstreamResource()->Deallocate(big_block.data, big_block.bytes,
|
||||||
big_block.alignment);
|
big_block.alignment);
|
||||||
unpooled_.clear();
|
unpooled_.clear();
|
||||||
|
last_alloc_pool_ = nullptr;
|
||||||
|
last_dealloc_pool_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PoolResource END
|
// PoolResource END
|
||||||
|
@ -219,6 +219,7 @@ TEST(PoolResource, SingleSmallBlockAllocations) {
|
|||||||
EXPECT_EQ(test_mem.delete_count_, 0U);
|
EXPECT_EQ(test_mem.delete_count_, 0U);
|
||||||
mem.Release();
|
mem.Release();
|
||||||
EXPECT_GE(test_mem.delete_count_, 2U);
|
EXPECT_GE(test_mem.delete_count_, 2U);
|
||||||
|
CheckAllocation(&mem, 64U, 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
||||||
@ -241,6 +242,7 @@ TEST(PoolResource, MultipleSmallBlockAllocations) {
|
|||||||
EXPECT_TRUE(test_mem.new_count_ >= 3U && test_mem.new_count_ <= 6U);
|
EXPECT_TRUE(test_mem.new_count_ >= 3U && test_mem.new_count_ <= 6U);
|
||||||
mem.Release();
|
mem.Release();
|
||||||
EXPECT_GE(test_mem.delete_count_, 6U);
|
EXPECT_GE(test_mem.delete_count_, 6U);
|
||||||
|
CheckAllocation(&mem, 64U);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
||||||
@ -260,6 +262,7 @@ TEST(PoolResource, BigBlockAllocations) {
|
|||||||
EXPECT_GE(test_mem.delete_count_, 1U);
|
EXPECT_GE(test_mem.delete_count_, 1U);
|
||||||
mem.Release();
|
mem.Release();
|
||||||
EXPECT_GE(test_mem.delete_count_, 3U);
|
EXPECT_GE(test_mem.delete_count_, 3U);
|
||||||
|
CheckAllocation(&mem, max_block_size + 1, 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
||||||
|
Loading…
Reference in New Issue
Block a user