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

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

Issue 2424393002: Constrain the zone segment pool size (Closed)
Patch Set: Fixing full size calculation 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..0a47e5c0cc4f5d975e81e5eda6c558a569d1c9d2 100644
--- a/src/zone/accounting-allocator.h
+++ b/src/zone/accounting-allocator.h
@@ -19,6 +19,11 @@ namespace internal {
class V8_EXPORT_PRIVATE AccountingAllocator {
public:
+ static const size_t kMaxPoolSizeLowMemoryDevice = 8ul * KB;
+ static const size_t kMaxPoolSizeMediumMemoryDevice = 1ul * MB;
+ static const size_t kMaxPoolSizeHighMemoryDevice = 2ul * MB;
+ static const size_t kMaxPoolSizeHugeMemoryDevice = 3ul * MB;
+
AccountingAllocator();
virtual ~AccountingAllocator();
@@ -34,6 +39,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 +47,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 =
jochen (gone - plz use gerrit) 2016/10/19 14:18:31 size_t please
+ 1 + kMaxSegmentSizePower - kMinSegmentSizePower;
+
// Allocates a new segment. Returns nullptr on failed allocation.
Segment* AllocateSegment(size_t bytes);
void FreeSegment(Segment* memory);
@@ -57,10 +65,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];
jochen (gone - plz use gerrit) 2016/10/19 14:18:31 same here also, members should end in _
jochen (gone - plz use gerrit) 2016/10/19 14:18:31 same here
+ uint8_t unused_segments_max_sizes[kNumberBuckets];
base::Mutex unused_segments_mutex_;

Powered by Google App Engine
This is Rietveld 408576698