Index: src/heap/spaces.cc |
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
index 17d2a70144b271c767270d2c87dbef185dec6042..7bcc65d5f9c8ed0177dc0c9d9d3087e13ea5b370 100644 |
--- a/src/heap/spaces.cc |
+++ b/src/heap/spaces.cc |
@@ -311,13 +311,7 @@ bool MemoryAllocator::SetUp(intptr_t capacity, intptr_t capacity_executable, |
void MemoryAllocator::TearDown() { |
- unmapper()->WaitUntilCompleted(); |
- |
- MemoryChunk* chunk = nullptr; |
- while ((chunk = unmapper()->TryGetPooledMemoryChunkSafe()) != nullptr) { |
- FreeMemory(reinterpret_cast<Address>(chunk), MemoryChunk::kPageSize, |
- NOT_EXECUTABLE); |
- } |
+ unmapper()->TearDown(); |
// Check that spaces were torn down before MemoryAllocator. |
DCHECK_EQ(size_.Value(), 0); |
@@ -384,6 +378,13 @@ void MemoryAllocator::Unmapper::PerformFreeMemoryOnQueuedChunks() { |
} |
} |
+void MemoryAllocator::Unmapper::TearDown() { |
+ WaitUntilCompleted(); |
+ ReconsiderDelayedChunks(); |
+ CHECK(delayed_regular_chunks_.empty()); |
+ PerformFreeMemoryOnQueuedChunks(); |
+} |
+ |
void MemoryAllocator::Unmapper::ReconsiderDelayedChunks() { |
std::list<MemoryChunk*> delayed_chunks(std::move(delayed_regular_chunks_)); |
// Move constructed, so the permanent list should be empty. |