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

Unified Diff: src/heap.h

Issue 7621014: Fix the thresholds so that the heap does not grow uncontrollably. This fixes (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 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 | « no previous file | src/heap.cc » ('j') | src/heap.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.h
===================================================================
--- src/heap.h (revision 8902)
+++ src/heap.h (working copy)
@@ -1209,11 +1209,40 @@
(PromotedSpaceSize() + PromotedExternalMemorySize());
}
- inline void LowerOldGenLimits(intptr_t bytes) {
- old_gen_promotion_limit_ -= bytes;
- old_gen_allocation_limit_ -= bytes;
+ static const intptr_t kMinimumPromotionLimit =
+ 2 * (Page::kPageSize > MB ? Page::kPageSize : MB);
+ static const intptr_t kMinimumAllocationLimit =
+ 8 * (Page::kPageSize > MB ? Page::kPageSize : MB);
+
+ // When we sweep lazily we initially guess that there is no garbage on the
+ // heap and set the limits for the next GC accordingly. As we sweep we find
+ // out that some of the pages contained garbage and we have to adjust
+ // downwards the size of the heap. This means the limits that control the
+ // timing of the next GC also need to be adjusted downwards.
+ void LowerOldGenLimits(intptr_t adjustment) {
+ size_of_old_gen_at_last_old_space_gc_ -= adjustment;
+ old_gen_promotion_limit_ =
+ OldGenPromotionLimit(size_of_old_gen_at_last_old_space_gc_);
+ old_gen_allocation_limit_ =
+ OldGenAllocationLimit(size_of_old_gen_at_last_old_space_gc_);
}
+ intptr_t OldGenPromotionLimit(intptr_t old_gen_size) {
+ intptr_t limit =
+ Max(old_gen_size + old_gen_size / 3, kMinimumPromotionLimit);
+ limit += new_space_.Capacity();
Vyacheslav Egorov (Chromium) 2011/08/12 09:11:51 new_space_.Capacity can change while lazy sweeping
Erik Corry 2011/08/12 09:21:48 No, but I don't think it matters.
+ limit *= old_gen_limit_factor_;
+ return limit;
+ }
+
+ intptr_t OldGenAllocationLimit(intptr_t old_gen_size) {
+ intptr_t limit =
+ Max(old_gen_size + old_gen_size / 2, kMinimumAllocationLimit);
+ limit += new_space_.Capacity();
+ limit *= old_gen_limit_factor_;
+ return limit;
+ }
+
// Can be called when the embedding application is idle.
bool IdleNotification();
@@ -1458,6 +1487,13 @@
// every allocation in large object space.
intptr_t old_gen_allocation_limit_;
+ // Sometimes the heuristics dictate that those limits are increased. This
+ // variable records that fact.
+ int old_gen_limit_factor_;
+
+ // Used to adjust the limits that control the timing of the next GC.
+ intptr_t size_of_old_gen_at_last_old_space_gc_;
+
// Limit on the amount of externally allocated memory allowed
// between global GCs. If reached a global GC is forced.
intptr_t external_allocation_limit_;
« no previous file with comments | « no previous file | src/heap.cc » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698