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

Side by Side Diff: third_party/tcmalloc/chromium/src/malloc_extension.cc

Issue 10820063: Enable memory profiler when TC_MALLOC is enabled for (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h ('k') | no next file » | 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) 2005, Google Inc. 1 // Copyright (c) 2012, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer 11 // copyright notice, this list of conditions and the following disclaimer
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #endif 43 #endif
44 #include <string> 44 #include <string>
45 #include "base/dynamic_annotations.h" 45 #include "base/dynamic_annotations.h"
46 #include "base/sysinfo.h" // for FillProcSelfMaps 46 #include "base/sysinfo.h" // for FillProcSelfMaps
47 #ifndef NO_HEAP_CHECK 47 #ifndef NO_HEAP_CHECK
48 #include "gperftools/heap-checker.h" 48 #include "gperftools/heap-checker.h"
49 #endif 49 #endif
50 #include "gperftools/malloc_extension.h" 50 #include "gperftools/malloc_extension.h"
51 #include "gperftools/malloc_extension_c.h" 51 #include "gperftools/malloc_extension_c.h"
52 #include "maybe_threads.h" 52 #include "maybe_threads.h"
53 #include "thread_cache.h"
53 54
54 using STL_NAMESPACE::string; 55 using STL_NAMESPACE::string;
55 using STL_NAMESPACE::vector; 56 using STL_NAMESPACE::vector;
56 57
57 static void DumpAddressMap(string* result) { 58 static void DumpAddressMap(string* result) {
58 *result += "\nMAPPED_LIBRARIES:\n"; 59 *result += "\nMAPPED_LIBRARIES:\n";
59 // We keep doubling until we get a fit 60 // We keep doubling until we get a fit
60 const size_t old_resultlen = result->size(); 61 const size_t old_resultlen = result->size();
61 for (int amap_size = 10240; amap_size < 10000000; amap_size *= 2) { 62 for (int amap_size = 10240; amap_size < 10000000; amap_size *= 2) {
62 result->resize(old_resultlen + amap_size); 63 result->resize(old_resultlen + amap_size);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // When running under valgrind, our custom malloc is replaced with 214 // When running under valgrind, our custom malloc is replaced with
214 // valgrind's one and malloc extensions will not work. (Note: 215 // valgrind's one and malloc extensions will not work. (Note:
215 // callers should be responsible for checking that they are the 216 // callers should be responsible for checking that they are the
216 // malloc that is really being run, before calling Register. This 217 // malloc that is really being run, before calling Register. This
217 // is just here as an extra sanity check.) 218 // is just here as an extra sanity check.)
218 if (!RunningOnValgrind()) { 219 if (!RunningOnValgrind()) {
219 current_instance = implementation; 220 current_instance = implementation;
220 } 221 }
221 } 222 }
222 223
224 unsigned int MallocExtension::GetBytesAllocatedOnCurrentThread() {
225 return tcmalloc::ThreadCache::GetBytesAllocatedOnCurrentThread();
226 }
227
223 // ----------------------------------------------------------------------- 228 // -----------------------------------------------------------------------
224 // Heap sampling support 229 // Heap sampling support
225 // ----------------------------------------------------------------------- 230 // -----------------------------------------------------------------------
226 231
227 namespace { 232 namespace {
228 233
229 // Accessors 234 // Accessors
230 uintptr_t Count(void** entry) { 235 uintptr_t Count(void** entry) {
231 return reinterpret_cast<uintptr_t>(entry[0]); 236 return reinterpret_cast<uintptr_t>(entry[0]);
232 } 237 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 C_SHIM(ReleaseToSystem, void, (size_t num_bytes), (num_bytes)); 368 C_SHIM(ReleaseToSystem, void, (size_t num_bytes), (num_bytes));
364 C_SHIM(GetEstimatedAllocatedSize, size_t, (size_t size), (size)); 369 C_SHIM(GetEstimatedAllocatedSize, size_t, (size_t size), (size));
365 C_SHIM(GetAllocatedSize, size_t, (const void* p), (p)); 370 C_SHIM(GetAllocatedSize, size_t, (const void* p), (p));
366 371
367 // Can't use the shim here because of the need to translate the enums. 372 // Can't use the shim here because of the need to translate the enums.
368 extern "C" 373 extern "C"
369 MallocExtension_Ownership MallocExtension_GetOwnership(const void* p) { 374 MallocExtension_Ownership MallocExtension_GetOwnership(const void* p) {
370 return static_cast<MallocExtension_Ownership>( 375 return static_cast<MallocExtension_Ownership>(
371 MallocExtension::instance()->GetOwnership(p)); 376 MallocExtension::instance()->GetOwnership(p));
372 } 377 }
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698