Commit c764215e authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Fix allocated_memory_size()

Bug: chromium:1056170
Change-Id: I4b43b78be23b8220b89f1ee5177f6b9b3c18146d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2764748
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73452}
parent 0b56c191
......@@ -224,7 +224,7 @@ void StatsCollector::NotifySweepingCompleted() {
}
size_t StatsCollector::allocated_memory_size() const {
return memory_allocated_bytes_;
return memory_allocated_bytes_ - memory_freed_bytes_since_end_of_marking_;
}
size_t StatsCollector::allocated_object_size() const {
......
......@@ -227,5 +227,13 @@ TEST_F(StatsCollectorTest, ObserverTriggersGC) {
stats.UnregisterObserver(&mock_observer);
}
TEST_F(StatsCollectorTest, AllocatedMemorySize) {
EXPECT_EQ(0u, stats.allocated_memory_size());
stats.NotifyAllocatedMemory(1024);
EXPECT_EQ(1024u, stats.allocated_memory_size());
stats.NotifyFreedMemory(1024);
EXPECT_EQ(0u, stats.allocated_memory_size());
}
} // namespace internal
} // namespace cppgc
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