Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Unified Diff: src/heap.cc

Issue 9233050: Reduce memory use immediately after boot. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/deoptimizer.cc ('k') | src/incremental-marking.cc » ('j') | src/spaces.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 10555)
+++ src/heap.cc (working copy)
@@ -582,10 +582,14 @@
PagedSpace* map_space = Heap::map_space();
PagedSpace* cell_space = Heap::cell_space();
LargeObjectSpace* lo_space = Heap::lo_space();
+ bool one_old_space_gc_has_been_performed = false;
bool gc_performed = true;
int counter = 0;
static const int kThreshold = 20;
+ bool old_space_gc_performed;
+
while (gc_performed && counter++ < kThreshold) {
Erik Corry 2012/01/31 10:44:44 This function was changed in response to the last
+ old_space_gc_performed = false;
gc_performed = false;
if (!new_space->ReserveSpace(new_space_size)) {
Heap::CollectGarbage(NEW_SPACE);
@@ -594,22 +598,27 @@
if (!old_pointer_space->ReserveSpace(pointer_space_size)) {
Heap::CollectGarbage(OLD_POINTER_SPACE);
gc_performed = true;
+ old_space_gc_performed = true;
}
if (!(old_data_space->ReserveSpace(data_space_size))) {
Heap::CollectGarbage(OLD_DATA_SPACE);
gc_performed = true;
+ old_space_gc_performed = true;
}
if (!(code_space->ReserveSpace(code_space_size))) {
Heap::CollectGarbage(CODE_SPACE);
gc_performed = true;
+ old_space_gc_performed = true;
}
if (!(map_space->ReserveSpace(map_space_size))) {
Heap::CollectGarbage(MAP_SPACE);
gc_performed = true;
+ old_space_gc_performed = true;
}
if (!(cell_space->ReserveSpace(cell_space_size))) {
Heap::CollectGarbage(CELL_SPACE);
gc_performed = true;
+ old_space_gc_performed = true;
}
// We add a slack-factor of 2 in order to have space for a series of
// large-object allocations that are only just larger than the page size.
@@ -619,15 +628,22 @@
// allocation in the other spaces.
large_object_size += cell_space_size + map_space_size + code_space_size +
data_space_size + pointer_space_size;
- if (!(lo_space->ReserveSpace(large_object_size))) {
+
+ // If we already did one GC in order to make space in old space, there is
+ // no sense in doing another one. We will attempt to force through the
+ // large object space allocation, which comes directly from the OS,
+ // regardless of any soft limit.
+ if (!one_old_space_gc_has_been_performed &&
+ !(lo_space->ReserveSpace(large_object_size))) {
Heap::CollectGarbage(LO_SPACE);
gc_performed = true;
}
+ if (old_space_gc_performed) one_old_space_gc_has_been_performed = true;
}
if (gc_performed) {
// Failed to reserve the space after several attempts.
- V8::FatalProcessOutOfMemory("Heap::ReserveSpace");
+ V8::FatalProcessOutOfMemory("Heap.:ReserveSpace");
Vyacheslav Egorov (Chromium) 2012/01/31 11:21:22 accidental edit?
}
}
« no previous file with comments | « src/deoptimizer.cc ('k') | src/incremental-marking.cc » ('j') | src/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698