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

Side by Side Diff: src/base/accounting-allocator.h

Issue 2050173002: [DoNotSubmit] Added peak_memory_size to accounting-allocator. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « src/api.cc ('k') | src/base/accounting-allocator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_BASE_ACCOUNTING_ALLOCATOR_H_ 5 #ifndef V8_BASE_ACCOUNTING_ALLOCATOR_H_
6 #define V8_BASE_ACCOUNTING_ALLOCATOR_H_ 6 #define V8_BASE_ACCOUNTING_ALLOCATOR_H_
7 7
8 #include "src/base/platform/mutex.h"
8 #include "src/base/atomicops.h" 9 #include "src/base/atomicops.h"
9 #include "src/base/macros.h" 10 #include "src/base/macros.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace base { 13 namespace base {
13 14
14 class AccountingAllocator final { 15 class AccountingAllocator final {
15 public: 16 public:
16 AccountingAllocator() = default; 17 AccountingAllocator() {}
17 ~AccountingAllocator() = default; 18 ~AccountingAllocator() {}
18 19
19 // Returns nullptr on failed allocation. 20 // Returns nullptr on failed allocation.
20 void* Allocate(size_t bytes); 21 void* Allocate(size_t bytes);
21 void Free(void* memory, size_t bytes); 22 void Free(void* memory, size_t bytes);
22 23
23 size_t GetCurrentMemoryUsage() const; 24 size_t GetCurrentMemoryUsage() const;
25 size_t GetPeakMemoryUsage() const;
24 26
25 private: 27 private:
26 AtomicWord current_memory_usage_ = 0; 28 size_t current_memory_usage_ = 0;
29 size_t peak_memory_usage_ = 0;
30 Mutex mutex_;
27 31
28 DISALLOW_COPY_AND_ASSIGN(AccountingAllocator); 32 DISALLOW_COPY_AND_ASSIGN(AccountingAllocator);
29 }; 33 };
30 34
31 } // namespace base 35 } // namespace base
32 } // namespace v8 36 } // namespace v8
33 37
34 #endif // V8_BASE_ACCOUNTING_ALLOCATOR_H_ 38 #endif // V8_BASE_ACCOUNTING_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/base/accounting-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698