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

Unified Diff: base/allocator/allocated_type_profiler_tcmalloc.cc

Issue 10411047: Type profiler by intercepting 'new' and 'delete' expressions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reflected Jim's comments. 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 side-by-side diff with in-line comments
Download patch
Index: base/allocator/allocated_type_profiler_tcmalloc.cc
diff --git a/base/allocator/allocated_type_profiler_tcmalloc.cc b/base/allocator/allocated_type_profiler_tcmalloc.cc
new file mode 100644
index 0000000000000000000000000000000000000000..82e58554c3ad84917f01d16381d0bd7609c7ddc5
--- /dev/null
+++ b/base/allocator/allocated_type_profiler_tcmalloc.cc
@@ -0,0 +1,38 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/allocator/allocated_type_profiler_tcmalloc.h"
+
+#if defined(PROFILING_ALLOCATED_TYPE)
+
+#include <gperftools/allocated_type_map.h>
+#include <gperftools/heap-profiler.h>
+
+#include "base/allocator/allocated_type_profiler_control.h"
+
+namespace base {
+namespace allocated_type_profiler {
+
+void* NewInterceptForTCMalloc(void* ptr,
+ size_t size,
+ const std::type_info& type) {
+ if (IsProfilingAllocatedType() && IsHeapProfilerRunning()) {
+ InsertAllocatedType(ptr, size, type);
+ }
jar (doing other things) 2012/08/27 17:17:13 nit: curlies not needed here, and on line 31.
Dai Mikurube (NOT FULLTIME) 2012/08/28 09:04:57 Done.
+ return ptr;
+}
+
+void* DeleteInterceptForTCMalloc(void* ptr,
+ size_t size,
+ const std::type_info& type) {
+ if (IsProfilingAllocatedType() && IsHeapProfilerRunning()) {
+ EraseAllocatedType(ptr);
+ }
+ return ptr;
+}
+
+} // namespace allocated_type_profiler
+} // namespace base
+
+#endif // defined(PROFILING_ALLOCATED_TYPE)

Powered by Google App Engine
This is Rietveld 408576698