Reviewers: Mads Ager, bak,

Description:
Update the Idle collector to do a full GC
after being idle for some time.


Please review this at http://codereview.chromium.org/174302

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     src/heap.h
   M     src/v8.cc


Index: src/v8.cc
===================================================================
--- src/v8.cc   (revision 2740)
+++ src/v8.cc   (working copy)
@@ -162,8 +162,8 @@
    // Ignore high priority instances of V8.
    if (is_high_priority) return;

-  // Uncommit unused memory in new space.
-  Heap::UncommitFromSpace();
+  // Tell the heap that it may want to adjust.
+  Heap::IdleNotification();
  }


Index: src/heap.h
===================================================================
--- src/heap.h  (revision 2740)
+++ src/heap.h  (working copy)
@@ -839,6 +839,29 @@
             > old_gen_allocation_limit_;
    }

+  // Can be called when the embedding application is idle.  If this  
routine is
+  // called repeatedly without JS activity, it will
+  static void IdleNotification() {
+    static const int kIdlesBeforeCollection = 10;
+    static int number_idle_notifications = 0;
+    static int last_gc_count = gc_count_;
+
+    if (last_gc_count == gc_count_) {
+      number_idle_notifications++;
+    } else {
+      number_idle_notifications = 0;
+      last_gc_count = gc_count_;
+    }
+
+    if (number_idle_notifications >= kIdlesBeforeCollection) {
+      CollectAllGarbage();
+      number_idle_notifications = 0;
+    }
+
+    // Uncommit unused memory in new space.
+    Heap::UncommitFromSpace();
+  }
+
   private:
    static int semispace_size_;
    static int initial_semispace_size_;



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to