Limit number of loop iterations in Heap::ReserveSpace.
This allows to avoid infinite loops in pathalogical cases e.g. when OS refuses to give new pages to V8. R=erik.corry@gmail.com BUG=99027 Review URL: https://chromiumcodereview.appspot.com/8286020 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10466 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
11e779185b
commit
8c776261c2
@ -583,7 +583,9 @@ void Heap::ReserveSpace(
|
|||||||
PagedSpace* cell_space = Heap::cell_space();
|
PagedSpace* cell_space = Heap::cell_space();
|
||||||
LargeObjectSpace* lo_space = Heap::lo_space();
|
LargeObjectSpace* lo_space = Heap::lo_space();
|
||||||
bool gc_performed = true;
|
bool gc_performed = true;
|
||||||
while (gc_performed) {
|
int counter = 0;
|
||||||
|
static const int kThreshold = 20;
|
||||||
|
while (gc_performed && counter++ < kThreshold) {
|
||||||
gc_performed = false;
|
gc_performed = false;
|
||||||
if (!new_space->ReserveSpace(new_space_size)) {
|
if (!new_space->ReserveSpace(new_space_size)) {
|
||||||
Heap::CollectGarbage(NEW_SPACE);
|
Heap::CollectGarbage(NEW_SPACE);
|
||||||
@ -622,6 +624,11 @@ void Heap::ReserveSpace(
|
|||||||
gc_performed = true;
|
gc_performed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gc_performed) {
|
||||||
|
// Failed to reserve the space after several attempts.
|
||||||
|
V8::FatalProcessOutOfMemory("Heap::ReserveSpace");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user