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

Unified Diff: src/heap.cc

Issue 7020020: Lower heap size limits on systems that are short of virtual memory. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 7 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/platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 8132)
+++ src/heap.cc (working copy)
@@ -152,6 +152,29 @@
max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
#endif
+ intptr_t max_virtual = OS::MaxVirtualMemory();
+
+ if (max_virtual > 0) {
+ // If we have limits on the amount of virtual memory we can use then we may
+ // be forced to lower the allocation limits. We reserve one quarter of the
+ // memory for young space and off-heap data. The rest is distributed as
+ // described below.
+ if (code_range_size_ > 0) {
Kasper Lund 2011/06/01 08:46:04 Maybe introduce two local variables, half and quar
+ // Reserve a quarter of the memory for the code range. The old space
+ // heap gets the remaining half. There is some unavoidable double
+ // counting going on here since the heap size is measured in committed
+ // virtual memory and the code range is only reserved virtual memory.
+ code_range_size_ = Min(code_range_size_, max_virtual >> 2);
+ max_old_generation_size_ =
+ Min(max_old_generation_size_, max_virtual >> 1);
+ } else {
+ // Reserve three quarters of the memory for the old space heap including
+ // the executable code.
+ max_old_generation_size_ = Min(max_old_generation_size_,
+ (max_virtual >> 2) + (max_virtual >> 1));
+ }
+ }
+
memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
global_contexts_list_ = NULL;
mark_compact_collector_.heap_ = this;
« no previous file with comments | « no previous file | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698