I am trying to test the retain cycle in Xcode 6. I Write 2 class, one is TTChild and another is TTParent. The header file of them are as follows.
@interface TTParent : NSObject
@property (nonatomic,strong) NSMutableArray *children;
@end
@interface TTChild : NSObject
@property (nonatomic,strong) TTParent *parent;
@end
And in the viewController class, I add one button, in the action method, I write the following code.
- (IBAction)ClickMe:(id)sender {
TTParent *parent = [[TTParent alloc] init];
parent.children = [[NSMutableArray alloc] init];
for (int i = 0; i < 1000; i++) {
TTChild *child = [[TTChild alloc] init];
child.parent = parent;
[parent.children addObject:child];
}
}
This code can lead to memory leak. The Child and Parent make the retain cycle.When I test it in the Xcode 6 leaks instrument, I click the button several times. And I saw the red line in the leaks area. Then I select the Leaks-> Cycles&Roots->Leaks cycle. But in the Graph column, there is nothing. It should have some graph to show the retain cycle situation, doesn't it? Can someone explain this question, if it should not, then in which situation will the Graph show. If someone can help me, thanks in advance.