Index: test/cctest/heap/test-heap.cc |
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc |
index 1b87564516c30aae876b7e31047ec3fdc29abfe7..7ee0c360ca92f20066c335b629abb69df2355166 100644 |
--- a/test/cctest/heap/test-heap.cc |
+++ b/test/cctest/heap/test-heap.cc |
@@ -6760,5 +6760,28 @@ TEST(Regress615489) { |
CHECK_LE(size_after, size_before); |
} |
+TEST(UncommitUnusedLargeObjectMemory) { |
+ CcTest::InitializeVM(); |
+ v8::HandleScope scope(CcTest::isolate()); |
+ Heap* heap = CcTest::heap(); |
+ Isolate* isolate = heap->isolate(); |
+ |
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(200000); |
+ MemoryChunk* chunk = MemoryChunk::FromAddress(array->address()); |
+ CHECK(chunk->owner()->identity() == LO_SPACE); |
+ |
+ intptr_t size_before = array->Size(); |
+ size_t committed_memory_before = chunk->CommittedPhysicalMemory(); |
+ |
+ array->Shrink(1); |
+ CHECK(array->Size() < size_before); |
+ |
+ CcTest::heap()->CollectAllGarbage(); |
+ CHECK(chunk->CommittedPhysicalMemory() < committed_memory_before); |
+ size_t shrinked_size = |
+ RoundUp((array->address() - chunk->address()) + array->Size(), |
+ base::OS::CommitPageSize()); |
+ CHECK_EQ(shrinked_size, chunk->CommittedPhysicalMemory()); |
+} |
} // namespace internal |
} // namespace v8 |