Commit 925a27c0 authored by iposva@chromium.org's avatar iposva@chromium.org

Partial fix for issue 173:

- Do not keep growing the zone segment size exponentially. By putting
  an upper limit on the segment size we limit the requirements for
  contiguous memory allocation.

Review URL: http://codereview.chromium.org/12984

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@926 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 89855a08
......@@ -163,8 +163,23 @@ Address Zone::NewExpand(int size) {
// is to avoid excessive malloc() and free() overhead.
Segment* head = Segment::head();
int old_size = (head == NULL) ? 0 : head->size();
int new_size = sizeof(Segment) + kAlignment + size + (old_size << 1);
if (new_size < kMinimumSegmentSize) new_size = kMinimumSegmentSize;
static const int kSegmentOverhead = sizeof(Segment) + kAlignment;
int new_size = kSegmentOverhead + size + (old_size << 1);
if (new_size < kMinimumSegmentSize) {
new_size = kMinimumSegmentSize;
} else if (new_size > kMaximumSegmentSize) {
// Limit the size of new segments to avoid growing the segment size
// exponentially, thus putting pressure on contiguous virtual address
// space.
if (size > (kMaximumSegmentSize - kSegmentOverhead)) {
// Make sure to allocate a segment at large enough to hold the requested
// size.
new_size = kSegmentOverhead + size;
} else {
// Allocate a new segment of maximum size.
new_size = kMaximumSegmentSize;
}
}
Segment* segment = Segment::New(new_size);
if (segment == NULL) V8::FatalProcessOutOfMemory("Zone");
......
......@@ -74,6 +74,9 @@ class Zone {
// Never allocate segments smaller than this size in bytes.
static const int kMinimumSegmentSize = 8 * KB;
// Never allocate segments larger than this size in bytes.
static const int kMaximumSegmentSize = 1 * MB;
// Never keep segments larger than this size in bytes around.
static const int kMaximumKeptSegmentSize = 64 * KB;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment