Commit ad93c01a authored by jochen's avatar jochen Committed by Commit bot

Track peak Zone memory usage and report it via HeapStatistics

BUG=
R=ulan@chromium.org,verwaest@chromium.org

Review-Url: https://codereview.chromium.org/2153423002
Cr-Commit-Position: refs/heads/master@{#37824}
parent db635d5b
......@@ -5248,6 +5248,7 @@ class V8_EXPORT HeapStatistics {
size_t used_heap_size() { return used_heap_size_; }
size_t heap_size_limit() { return heap_size_limit_; }
size_t malloced_memory() { return malloced_memory_; }
size_t peak_malloced_memory() { return peak_malloced_memory_; }
size_t does_zap_garbage() { return does_zap_garbage_; }
private:
......@@ -5258,6 +5259,7 @@ class V8_EXPORT HeapStatistics {
size_t used_heap_size_;
size_t heap_size_limit_;
size_t malloced_memory_;
size_t peak_malloced_memory_;
bool does_zap_garbage_;
friend class V8;
......
......@@ -5619,6 +5619,7 @@ HeapStatistics::HeapStatistics()
used_heap_size_(0),
heap_size_limit_(0),
malloced_memory_(0),
peak_malloced_memory_(0),
does_zap_garbage_(0) {}
HeapSpaceStatistics::HeapSpaceStatistics(): space_name_(0),
......@@ -7597,6 +7598,8 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
heap_statistics->heap_size_limit_ = heap->MaxReserved();
heap_statistics->malloced_memory_ =
isolate->allocator()->GetCurrentMemoryUsage();
heap_statistics->peak_malloced_memory_ =
isolate->allocator()->GetMaxMemoryUsage();
heap_statistics->does_zap_garbage_ = heap->ShouldZapGarbage();
}
......
......@@ -15,7 +15,14 @@ namespace base {
void* AccountingAllocator::Allocate(size_t bytes) {
void* memory = malloc(bytes);
if (memory) NoBarrier_AtomicIncrement(&current_memory_usage_, bytes);
if (memory) {
AtomicWord current =
NoBarrier_AtomicIncrement(&current_memory_usage_, bytes);
AtomicWord max = NoBarrier_Load(&max_memory_usage_);
while (current > max) {
max = NoBarrier_CompareAndSwap(&max_memory_usage_, max, current);
}
}
return memory;
}
......@@ -29,5 +36,9 @@ size_t AccountingAllocator::GetCurrentMemoryUsage() const {
return NoBarrier_Load(&current_memory_usage_);
}
size_t AccountingAllocator::GetMaxMemoryUsage() const {
return NoBarrier_Load(&max_memory_usage_);
}
} // namespace base
} // namespace v8
......@@ -21,9 +21,11 @@ class AccountingAllocator final {
void Free(void* memory, size_t bytes);
size_t GetCurrentMemoryUsage() const;
size_t GetMaxMemoryUsage() const;
private:
AtomicWord current_memory_usage_ = 0;
AtomicWord max_memory_usage_ = 0;
DISALLOW_COPY_AND_ASSIGN(AccountingAllocator);
};
......
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