Index: src/zone.cc |
=================================================================== |
--- src/zone.cc (revision 918) |
+++ src/zone.cc (working copy) |
@@ -163,8 +163,23 @@ |
// 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; |
+ int segment_overhead = sizeof(Segment) + kAlignment; |
Kasper Lund
2008/12/05 08:36:49
This is a constant, right? Maybe make it 'static c
iposva
2008/12/05 17:25:13
Done.
|
+ int new_size = segment_overhead + 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 - segment_overhead)) { |
+ // Make sure to allocate a segment at least large enough to hold the |
+ // requested size. |
+ new_size = RoundUp(size + segment_overhead, kMinimumSegmentSize); |
Kasper Lund
2008/12/05 08:36:49
Why do you round the result up? If it's a feature
iposva
2008/12/05 17:25:13
The idea was to round up to a size that is likely
|
+ } else { |
+ // Allocate a new segment of maximum size. |
+ new_size = kMaximumSegmentSize; |
+ } |
+ } |
Segment* segment = Segment::New(new_size); |
if (segment == NULL) V8::FatalProcessOutOfMemory("Zone"); |