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

Side by Side Diff: base/allocator/allocator_extension.cc

Issue 1607303002: Allocator cleanup: allocator_extension call directly into tcmalloc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_dep_alloc
Patch Set: rebase Created 4 years, 11 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 | « base/allocator/allocator_extension.h ('k') | base/debug/OWNERS » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 #include "base/allocator/allocator_extension.h" 5 #include "base/allocator/allocator_extension.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 #if defined(USE_TCMALLOC)
10 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
11 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
12 #endif
13
9 namespace base { 14 namespace base {
10 namespace allocator { 15 namespace allocator {
11 16
12 namespace {
13 ReleaseFreeMemoryFunction g_release_free_memory_function = nullptr;
14 GetNumericPropertyFunction g_get_numeric_property_function = nullptr;
15 }
16
17 void ReleaseFreeMemory() { 17 void ReleaseFreeMemory() {
18 if (g_release_free_memory_function) 18 #if defined(USE_TCMALLOC)
19 g_release_free_memory_function(); 19 ::MallocExtension::instance()->ReleaseFreeMemory();
20 #endif
20 } 21 }
21 22
22 bool GetNumericProperty(const char* name, size_t* value) { 23 bool GetNumericProperty(const char* name, size_t* value) {
23 return g_get_numeric_property_function && 24 #if defined(USE_TCMALLOC)
24 g_get_numeric_property_function(name, value); 25 return ::MallocExtension::instance()->GetNumericProperty(name, value);
26 #endif
27 return false;
25 } 28 }
26 29
27 void SetReleaseFreeMemoryFunction( 30 bool IsHeapProfilerRunning() {
28 ReleaseFreeMemoryFunction release_free_memory_function) { 31 #if defined(USE_TCMALLOC)
29 DCHECK(!g_release_free_memory_function); 32 return ::IsHeapProfilerRunning();
30 g_release_free_memory_function = release_free_memory_function; 33 #endif
31 } 34 return false;
32
33 void SetGetNumericPropertyFunction(
34 GetNumericPropertyFunction get_numeric_property_function) {
35 DCHECK(!g_get_numeric_property_function);
36 g_get_numeric_property_function = get_numeric_property_function;
37 } 35 }
38 36
39 } // namespace allocator 37 } // namespace allocator
40 } // namespace base 38 } // namespace base
OLDNEW
« no previous file with comments | « base/allocator/allocator_extension.h ('k') | base/debug/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698