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

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

Issue 1847543002: Expose a lower bound of malloc'd memory via heap statistics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 8 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/base/accounting-allocator.h ('k') | src/builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/base/accounting-allocator.h"
6
7 #include <cstdlib>
8
9 #if V8_LIBC_BIONIC
10 #include <malloc.h> // NOLINT
11 #endif
12
13 namespace v8 {
14 namespace base {
15
16 void* AccountingAllocator::Allocate(size_t bytes) {
17 void* memory = malloc(bytes);
18 if (memory) NoBarrier_AtomicIncrement(&current_memory_usage_, bytes);
19 return memory;
20 }
21
22 void AccountingAllocator::Free(void* memory, size_t bytes) {
23 free(memory);
24 NoBarrier_AtomicIncrement(&current_memory_usage_,
25 -static_cast<AtomicWord>(bytes));
26 }
27
28 size_t AccountingAllocator::GetCurrentMemoryUsage() const {
29 return NoBarrier_Load(&current_memory_usage_);
30 }
31
32 } // namespace base
33 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/accounting-allocator.h ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698