Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / base / debug / leak_annotations.h
blob51adfb05d6c7b22c1604a52357f95cf8bdae6617
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
3 // found in the LICENSE file.
5 #ifndef BASE_DEBUG_LEAK_ANNOTATIONS_H_
6 #define BASE_DEBUG_LEAK_ANNOTATIONS_H_
8 #include "build/build_config.h"
10 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_NACL) && \
11 defined(USE_HEAPCHECKER)
13 #include "third_party/tcmalloc/chromium/src/gperftools/heap-checker.h"
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
17 // and should not be used in the production code.
18 #define ANNOTATE_SCOPED_MEMORY_LEAK \
19 HeapLeakChecker::Disabler heap_leak_checker_disabler
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.
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)
32 #else
34 // If tcmalloc is not used, the annotations should be no-ops.
35 #define ANNOTATE_SCOPED_MEMORY_LEAK ((void)0)
36 #define ANNOTATE_LEAKING_OBJECT_PTR(X) ((void)0)
38 #endif
40 #endif // BASE_DEBUG_LEAK_ANNOTATIONS_H_