Commit 2c333251 authored by ulan@chromium.org's avatar ulan@chromium.org

Fix estimation of released pages when collecting evacuation candidates.

Do at least two GCs in LowMemoryNotification.

R=mstarzinger@chromium.org

Review URL: https://chromiumcodereview.appspot.com/18635006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15554 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ed6d2d5c
...@@ -613,8 +613,10 @@ void Heap::CollectAllAvailableGarbage(const char* gc_reason) { ...@@ -613,8 +613,10 @@ void Heap::CollectAllAvailableGarbage(const char* gc_reason) {
kReduceMemoryFootprintMask); kReduceMemoryFootprintMask);
isolate_->compilation_cache()->Clear(); isolate_->compilation_cache()->Clear();
const int kMaxNumberOfAttempts = 7; const int kMaxNumberOfAttempts = 7;
const int kMinNumberOfAttempts = 2;
for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) {
if (!CollectGarbage(OLD_POINTER_SPACE, MARK_COMPACTOR, gc_reason, NULL)) { if (!CollectGarbage(OLD_POINTER_SPACE, MARK_COMPACTOR, gc_reason, NULL) &&
attempt + 1 >= kMinNumberOfAttempts) {
break; break;
} }
} }
......
...@@ -781,10 +781,12 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) { ...@@ -781,10 +781,12 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
} }
if (FLAG_trace_fragmentation && mode == REDUCE_MEMORY_FOOTPRINT) { if (FLAG_trace_fragmentation && mode == REDUCE_MEMORY_FOOTPRINT) {
PrintF("Estimated over reserved memory: %.1f / %.1f MB (threshold %d)\n", PrintF("Estimated over reserved memory: %.1f / %.1f MB (threshold %d), "
"evacuation candidate limit: %d\n",
static_cast<double>(over_reserved) / MB, static_cast<double>(over_reserved) / MB,
static_cast<double>(reserved) / MB, static_cast<double>(reserved) / MB,
static_cast<int>(kFreenessThreshold)); static_cast<int>(kFreenessThreshold),
max_evacuation_candidates);
} }
intptr_t estimated_release = 0; intptr_t estimated_release = 0;
...@@ -811,7 +813,7 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) { ...@@ -811,7 +813,7 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
if ((counter & 1) == (page_number & 1)) fragmentation = 1; if ((counter & 1) == (page_number & 1)) fragmentation = 1;
} else if (mode == REDUCE_MEMORY_FOOTPRINT) { } else if (mode == REDUCE_MEMORY_FOOTPRINT) {
// Don't try to release too many pages. // Don't try to release too many pages.
if (estimated_release >= ((over_reserved * 3) / 4)) { if (estimated_release >= over_reserved) {
continue; continue;
} }
...@@ -828,7 +830,7 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) { ...@@ -828,7 +830,7 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
int free_pct = static_cast<int>(free_bytes * 100) / p->area_size(); int free_pct = static_cast<int>(free_bytes * 100) / p->area_size();
if (free_pct >= kFreenessThreshold) { if (free_pct >= kFreenessThreshold) {
estimated_release += 2 * p->area_size() - free_bytes; estimated_release += free_bytes;
fragmentation = free_pct; fragmentation = free_pct;
} else { } else {
fragmentation = 0; fragmentation = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment