Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Make GC less aggressive for big heaps
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed May 4, 2012
1 parent 992e346 commit 92afcaa
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/node.cc
Expand Up @@ -183,10 +183,10 @@ static void StopGCTimer () {
static void Idle(uv_idle_t* watcher, int status) {
assert((uv_idle_t*) watcher == &gc_idle);

if (V8::IdleNotification()) {
uv_idle_stop(&gc_idle);
StopGCTimer();
}
V8::IdleNotification();

uv_idle_stop(&gc_idle);
StopGCTimer();
}


Expand Down Expand Up @@ -1415,10 +1415,16 @@ static void CheckStatus(uv_timer_t* watcher, int status) {
if (!uv_is_active((uv_handle_t*) &gc_idle)) {
HeapStatistics stats;
V8::GetHeapStatistics(&stats);
if (stats.total_heap_size() > 1024 * 1024 * 128) {
// larger than 128 megs, just start the idle watcher
uv_idle_start(&gc_idle, node::Idle);
return;
uint64_t heap_size = stats.total_heap_size();
if (heap_size > 1024 * 1024 * 128);
uint64_t heap_used = stats.used_heap_size();
uint64_t heap_used_percent = (heap_used * 100) / heap_size;
if (heap_used_percent > 75) {
// larger than 128 megs and more than 75% full, just start the idle
// watcher
uv_idle_start(&gc_idle, node::Idle);
return;
}
}
}

Expand Down

0 comments on commit 92afcaa

Please sign in to comment.