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

Unified Diff: src/zone/accounting-allocator.h

Issue 2424393002: Constrain the zone segment pool size (Closed)
Patch Set: Fixed overflow Created 4 years, 2 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
Index: src/zone/accounting-allocator.h
diff --git a/src/zone/accounting-allocator.h b/src/zone/accounting-allocator.h
index f519c45db33637bbc78bbe3c0539269b17ab30db..035d610ba3d3d9bf679cf81890707e4bb4f91301 100644
--- a/src/zone/accounting-allocator.h
+++ b/src/zone/accounting-allocator.h
@@ -34,6 +34,7 @@ class V8_EXPORT_PRIVATE AccountingAllocator {
size_t GetCurrentPoolSize() const;
void MemoryPressureNotification(MemoryPressureLevel level);
+ void ConfigureSegmentPool(const size_t max_pool_size);
virtual void ZoneCreation(const Zone* zone) {}
virtual void ZoneDestruction(const Zone* zone) {}
@@ -41,10 +42,12 @@ class V8_EXPORT_PRIVATE AccountingAllocator {
private:
static const uint8_t kMinSegmentSizePower = 13;
static const uint8_t kMaxSegmentSizePower = 18;
- static const uint8_t kMaxSegmentsPerBucket = 5;
STATIC_ASSERT(kMinSegmentSizePower <= kMaxSegmentSizePower);
+ static const uint8_t kNumberBuckets =
+ 1 + kMaxSegmentSizePower - kMinSegmentSizePower;
+
// Allocates a new segment. Returns nullptr on failed allocation.
Segment* AllocateSegment(size_t bytes);
void FreeSegment(Segment* memory);
@@ -57,10 +60,10 @@ class V8_EXPORT_PRIVATE AccountingAllocator {
// Empties the pool and puts all its contents onto the garbage stack.
void ClearPool();
- Segment*
- unused_segments_heads_[1 + kMaxSegmentSizePower - kMinSegmentSizePower];
+ Segment* unused_segments_heads_[kNumberBuckets];
- size_t unused_segments_sizes[1 + kMaxSegmentSizePower - kMinSegmentSizePower];
+ uint8_t unused_segments_sizes[kNumberBuckets];
+ uint8_t unused_segments_max_sizes[kNumberBuckets];
base::Mutex unused_segments_mutex_;
« src/api.cc ('K') | « src/api.cc ('k') | src/zone/accounting-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698