| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef BASE_LEAK_TRACKER_H_ | 5 #ifndef BASE_LEAK_TRACKER_H_ |
| 6 #define BASE_LEAK_TRACKER_H_ | 6 #define BASE_LEAK_TRACKER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // Only enable leak tracking in debug builds. | 9 // Only enable leak tracking in debug builds. |
| 10 #ifndef NDEBUG | 10 #ifndef NDEBUG |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 for (LinkNode<LeakTracker<T> >* node = instances()->head(); | 84 for (LinkNode<LeakTracker<T> >* node = instances()->head(); |
| 85 node != instances()->end(); | 85 node != instances()->end(); |
| 86 node = node->next()) { | 86 node = node->next()) { |
| 87 StackTrace& allocation_stack = node->value()->allocation_stack_; | 87 StackTrace& allocation_stack = node->value()->allocation_stack_; |
| 88 | 88 |
| 89 if (count < kMaxStackTracesToCopyOntoStack) | 89 if (count < kMaxStackTracesToCopyOntoStack) |
| 90 stacktraces[count] = allocation_stack; | 90 stacktraces[count] = allocation_stack; |
| 91 | 91 |
| 92 ++count; | 92 ++count; |
| 93 LOG(ERROR) << "Leaked " << node << " which was allocated by:"; | 93 LOG(ERROR) << "Leaked " << node << " which was allocated by:"; |
| 94 allocation_stack.OutputToStream(&LOG_STREAM(ERROR)); | 94 allocation_stack.OutputToStream(&LOG(ERROR)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 CHECK_EQ(0u, count); | 97 CHECK_EQ(0u, count); |
| 98 | 98 |
| 99 // Hack to keep |stacktraces| and |count| alive (so compiler | 99 // Hack to keep |stacktraces| and |count| alive (so compiler |
| 100 // doesn't optimize it out, and it will appear in mini-dumps). | 100 // doesn't optimize it out, and it will appear in mini-dumps). |
| 101 if (count == 0x1234) { | 101 if (count == 0x1234) { |
| 102 for (size_t i = 0; i < kMaxStackTracesToCopyOntoStack; ++i) | 102 for (size_t i = 0; i < kMaxStackTracesToCopyOntoStack; ++i) |
| 103 stacktraces[i].PrintBacktrace(); | 103 stacktraces[i].PrintBacktrace(); |
| 104 } | 104 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 StackTrace allocation_stack_; | 125 StackTrace allocation_stack_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 #endif // ENABLE_LEAK_TRACKER | 128 #endif // ENABLE_LEAK_TRACKER |
| 129 | 129 |
| 130 } // namespace base | 130 } // namespace base |
| 131 | 131 |
| 132 #endif // BASE_LEAK_TRACKER_H_ | 132 #endif // BASE_LEAK_TRACKER_H_ |
| OLD | NEW |