/
FBRetainCycleDetector.h
85 lines (65 loc) · 3 KB
/
FBRetainCycleDetector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
//! Project version number for FBRetainCycleDetector.
FOUNDATION_EXPORT double FBRetainCycleDetectorVersionNumber;
//! Project version string for FBRetainCycleDetector.
FOUNDATION_EXPORT const unsigned char FBRetainCycleDetectorVersionString[];
#import <FBRetainCycleDetector/FBAssociationManager.h>
#import <FBRetainCycleDetector/FBObjectiveCBlock.h>
#import <FBRetainCycleDetector/FBObjectiveCGraphElement.h>
#import <FBRetainCycleDetector/FBObjectiveCNSCFTimer.h>
#import <FBRetainCycleDetector/FBObjectiveCObject.h>
#import <FBRetainCycleDetector/FBObjectGraphConfiguration.h>
#import <FBRetainCycleDetector/FBStandardGraphEdgeFilters.h>
/**
Retain Cycle Detector is enabled by default in DEBUG builds, but you can also force it in other builds by
uncommenting the line below. Beware, Retain Cycle Detector uses some private APIs that shouldn't be compiled in
production builds.
*/
//#define RETAIN_CYCLE_DETECTOR_ENABLED 1
/**
FBRetainCycleDetector
The main class responsible for detecting retain cycles.
Be cautious, the class is NOT thread safe.
The process of detecting retain cycles is relatively slow and consumes a lot of CPU.
*/
@interface FBRetainCycleDetector : NSObject
/**
Designated initializer
@param configuration Configuration for detector. Can include specific filters and options.
@see FBRetainCycleDetectorConfiguration
*/
- (nonnull instancetype)initWithConfiguration:(nonnull FBObjectGraphConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
/**
Adds candidate you are interested in getting retain cycles from.
@param candidate Any Objective-C object you want to verify for cycles.
*/
- (void)addCandidate:(nonnull id)candidate;
/**
Searches for all retain cycles for all candidates the detector has been
provided with.
@return NSSet with retain cycles. An element of this array will be
an array representing retain cycle. That array will hold elements
of type FBObjectiveCGraphElement.
@discussion For given candidate, the detector will go through all object graph rooted in this candidate and return
ALL retain cycles that this candidate references. It will also take care of removing duplicates. It will not look for
cycles longer than 10 elements. If you want to look for longer ones use findRetainCyclesWithMaxCycleLenght:
*/
- (nonnull NSSet<NSArray<FBObjectiveCGraphElement *> *> *)findRetainCycles;
- (nonnull NSSet<NSArray<FBObjectiveCGraphElement *> *> *)findRetainCyclesWithMaxCycleLength:(NSUInteger)length;
/**
This macro is used across FBRetainCycleDetector to compile out sensitive code.
If you do not define it anywhere, Retain Cycle Detector will be available in DEBUG builds.
*/
#ifdef RETAIN_CYCLE_DETECTOR_ENABLED
#define _INTERNAL_RCD_ENABLED RETAIN_CYCLE_DETECTOR_ENABLED
#else
#define _INTERNAL_RCD_ENABLED DEBUG
#endif
@end