Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index abeaf078042951cfef912f33e4cc69dfe592be8e..7c379f3f29965a0f1e726971c1a87d56575c0407 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -571,7 +571,9 @@ void Heap::ReserveSpace( |
PagedSpace* cell_space = Heap::cell_space(); |
LargeObjectSpace* lo_space = Heap::lo_space(); |
bool gc_performed = true; |
- while (gc_performed) { |
+ int counter = 0; |
+ static const int kThreshold = 20; |
+ while (gc_performed && counter++ < kThreshold) { |
gc_performed = false; |
if (!new_space->ReserveSpace(new_space_size)) { |
Heap::CollectGarbage(NEW_SPACE); |
@@ -610,6 +612,11 @@ void Heap::ReserveSpace( |
gc_performed = true; |
} |
} |
+ |
+ if (gc_performed) { |
+ // Failed to reserve the space after several attempts. |
+ V8::FatalProcessOutOfMemory("Heap::ReserveSpace"); |
+ } |
} |