2017-05-26 1 views
0

私はサイクルを保持しますが、プロファイリングでは、ツールは、この保持obiviousサイクルXCodeのメモリプロファイルツールはこのような保持サイクルを検出できません。

まず、のViewControllerは、プロパティsubVCとしてSubViewControllerを保持し、かつSubViewControllerのデリゲートとして設定することを見つけることができないようです。

@interface ViewController()<TestDelegate> 
@property(nonatomic,strong) UIViewController* subVC; 
@end 

@implementation ViewController 

- (void)dealloc 
{ 
    NSLog(@"ViewController dealloc"); 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 


- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 
{ 
    SubViewController* subVC = [[SubViewController alloc] init]; 
    subVC.delegate = self; 
    self.subVC = subVC; 
    [self presentViewController:subVC animated:YES completion:nil]; 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (void)didSelect 
{ 

} 
@end 

そしてSubViewControllerに、デリゲートは私はすべてのヒープ間のパネルを切り替える場合は[OK]を、今のツールだけ働いているようだデリゲート

@protocol TestDelegate <NSObject> 
@optional 
- (void)didSelect; 
@end 

@interface SubViewController : UIViewController 
@property(nonatomic,strong) id<TestDelegate> delegate; 
@end 

@interface SubViewController() 

@end 

@implementation SubViewController 

- (void)dealloc 
{ 
    NSLog(@"SubViewController dealloc"); 
} 

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 
{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

/* 
#pragma mark - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    // Get the new view controller using [segue destinationViewController]. 
    // Pass the selected object to the new view controller. 
} 
*/ 

@end 

答えて

0

を保持するための強力なプロパティとして設定されています&漏れチェック。そして、もし私がそれらのスイッチを入れないなら。保持サイクルは決して見つからないだろう。 enter image description here

関連する問題