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

Unified Diff: src/heap.h

Issue 174302: Update the Idle collector to do a full GC (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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/api.cc ('k') | src/heap-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.h
===================================================================
--- src/heap.h (revision 2740)
+++ src/heap.h (working copy)
@@ -629,7 +629,7 @@
// Performs a full garbage collection. Force compaction if the
// parameter is true.
- static void CollectAllGarbage(bool force_compaction = false);
+ static void CollectAllGarbage(bool force_compaction);
// Performs a full garbage collection if a context has been disposed
// since the last time the check was performed.
@@ -839,6 +839,33 @@
> old_gen_allocation_limit_;
}
+ // Can be called when the embedding application is idle.
+ static bool IdleNotification() {
+ static const int kIdlesBeforeCollection = 7;
+ static int number_idle_notifications = 0;
+ static int last_gc_count = gc_count_;
+
+ bool finished = false;
+
+ if (last_gc_count == gc_count_) {
+ number_idle_notifications++;
+ } else {
+ number_idle_notifications = 0;
+ last_gc_count = gc_count_;
+ }
+
+ if (number_idle_notifications >= kIdlesBeforeCollection) {
+ bool force_compaction = true;
+ CollectAllGarbage(force_compaction);
+ number_idle_notifications = 0;
+ finished = true;
+ }
+
+ // Uncommit unused memory in new space.
+ Heap::UncommitFromSpace();
+ return finished;
+ }
+
private:
static int semispace_size_;
static int initial_semispace_size_;
« no previous file with comments | « src/api.cc ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698