Chromium Code Reviews| Index: base/allocator/allocated_type_profiler_log.cc |
| diff --git a/base/allocator/allocated_type_profiler_log.cc b/base/allocator/allocated_type_profiler_log.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f20efe32e09dfe676d8892a9444a569618d4613d |
| --- /dev/null |
| +++ b/base/allocator/allocated_type_profiler_log.cc |
| @@ -0,0 +1,34 @@ |
| +// Copyright (c) 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 "allocated_type_profiler.h" |
| +#include <iostream> |
| + |
| +void* __op_new_intercept__(void* ptr, |
| + size_t size, |
| + const std::type_info& type) { |
| + std::cerr << "Allocated " |
| + << size |
| + << "bytes as an instance of \"" |
| + << type.name() |
| + << "\" at " |
| + << ptr |
| + << "." |
| + << std::endl; |
|
Ryan Sleevi
2012/08/10 04:16:09
style nit: Please see the comments on http://www.c
Dai Mikurube (NOT FULLTIME)
2012/08/10 07:30:03
Do you mean I should do the following?
std::cerr
Ryan Sleevi
2012/08/10 09:38:50
Yes, I believe that to be more readable.
Dai Mikurube (NOT FULLTIME)
2012/08/13 08:32:14
(1). Non-tcmalloc binaries are sometimes switched
|
| + return ptr; |
| +} |
| + |
| +void* __op_delete_intercept__(void* ptr, |
| + size_t size, |
| + const std::type_info& type) { |
| + std::cerr << "Dellocated " |
| + << size |
| + << "bytes of an instance of \"" |
|
Ryan Sleevi
2012/08/10 04:16:09
" bytes" (note the extra space)
same on 13
Dai Mikurube (NOT FULLTIME)
2012/08/10 07:30:03
Done.
|
| + << type.name() |
| + << "\" at " |
| + << ptr |
| + << "." |
| + << std::endl; |
|
Ryan Sleevi
2012/08/10 04:16:09
perf nit: std::endl is going to force a sync flush
Dai Mikurube (NOT FULLTIME)
2012/08/10 07:30:03
Flushing is better for the purpose written in the
|
| + return ptr; |
| +} |