OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DEBUG_LEAK_ANNOTATIONS_H_ | 5 #ifndef BASE_DEBUG_LEAK_ANNOTATIONS_H_ |
6 #define BASE_DEBUG_LEAK_ANNOTATIONS_H_ | 6 #define BASE_DEBUG_LEAK_ANNOTATIONS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #if defined(OS_LINUX) && defined(USE_HEAPCHECKER) | 11 #if defined(OS_LINUX) && defined(USE_HEAPCHECKER) |
12 | 12 |
13 #include "third_party/tcmalloc/chromium/src/google/heap-checker.h" | 13 #include "third_party/tcmalloc/chromium/src/google/heap-checker.h" |
14 | 14 |
15 // Annotate a program scope as having memory leaks. Tcmalloc's heap leak | 15 // Annotate a program scope as having memory leaks. Tcmalloc's heap leak |
16 // checker will ignore them. Note that these annotations may mask real bugs | 16 // checker will ignore them. Note that these annotations may mask real bugs |
17 // and should not be used in the production code. | 17 // and should not be used in the production code. |
18 #define ANNOTATE_SCOPED_MEMORY_LEAK \ | 18 #define ANNOTATE_SCOPED_MEMORY_LEAK \ |
19 HeapLeakChecker::Disabler heap_leak_checker_disabler | 19 HeapLeakChecker::Disabler heap_leak_checker_disabler |
20 | 20 |
| 21 // Annotate an object pointer as referencing a leaky object. This object and all |
| 22 // the heap objects referenced by it will be ignored by the heap checker. |
| 23 // |
| 24 // X should be referencing an active allocated object. If it is not, the |
| 25 // annotation will be ignored. |
| 26 // No object should be annotated with ANNOTATE_SCOPED_MEMORY_LEAK twice. |
| 27 // Once an object is annotated with ANNOTATE_SCOPED_MEMORY_LEAK, it cannot be |
| 28 // deleted. |
| 29 #define ANNOTATE_LEAKING_OBJECT_PTR(X) \ |
| 30 HeapLeakChecker::IgnoreObject(X) |
| 31 |
21 #else | 32 #else |
22 | 33 |
23 // If tcmalloc is not used, the annotations should be no-ops. | 34 // If tcmalloc is not used, the annotations should be no-ops. |
24 #define ANNOTATE_SCOPED_MEMORY_LEAK | 35 #define ANNOTATE_SCOPED_MEMORY_LEAK |
| 36 #define ANNOTATE_LEAKING_OBJECT_PTR(X) |
25 | 37 |
26 #endif | 38 #endif |
27 | 39 |
28 #endif // BASE_DEBUG_LEAK_ANNOTATIONS_H_ | 40 #endif // BASE_DEBUG_LEAK_ANNOTATIONS_H_ |
OLD | NEW |