Commit a3632a56 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Calculate committed after used memory

Fix dcheck failure where committed was smaller than used memory. This was because of background threads allocating between calculating both stats and used memory could already be larger due to those background allocations. Avoid this first calculating used memory and committed memory afterwards.

Bug: v8:10563, v8:10315
Change-Id: Ic07970f607941140e3028bddde3e365b66aa4b5f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2237138
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68256}
parent d6794def
......@@ -1664,8 +1664,12 @@ bool Heap::CollectGarbage(AllocationSpace space,
}
if (collector == MARK_COMPACTOR) {
size_t committed_memory_after = CommittedOldGenerationMemory();
// Calculate used memory first, then committed memory. Following code
// assumes that committed >= used, which might not hold when this is
// calculated in the wrong order and background threads allocate
// in-between.
size_t used_memory_after = OldGenerationSizeOfObjects();
size_t committed_memory_after = CommittedOldGenerationMemory();
MemoryReducer::Event event;
event.type = MemoryReducer::kMarkCompact;
event.time_ms = MonotonicallyIncreasingTimeInMs();
......
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