[英]Modally presented UIViewController does not empty memory on close
I have a problem, that caused me quite some hours/days of debugging so far. 我有一个问题,到目前为止,这已经导致我花了很多小时/天进行调试。
My situation is: 我的情况是:
I do not hold references (either weak or strong) for the modal view anywhere. 我在任何地方都没有模态视图的引用(弱引用或强引用)。
This is how the segue is performed: 这是segue的执行方式:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UINavigationController *nav = [segue destinationViewController];
SomeViewController *vc = (SomeViewController *)[nav topViewController];
vc.dataArray = self.dataArray; // dataArray is a weak reference
}
And this is how i close it: 这就是我关闭它的方式:
-(void)closeButtonClickHandler:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
In my viewDidDisapear method, i set everything to nil 在我的viewDidDisapear方法中,我将所有内容都设置为nil
- (void)viewDidDisappear:(BOOL)animated
{
[self.map removeAnnotations:self.myMap.annotations];
self.map.delegate = nil;
self.map = nil;
self.view = nil;
[super viewDidDisappear:animated];
}
But the controller still remains in memory. 但是控制器仍保留在内存中。 What is even worse is, that if i open it multiple times, it keeps adding to the consumed memory until eventually the OS is forced to close the application. 更糟糕的是,如果我多次打开它,它将一直添加到消耗的内存中,直到最终迫使操作系统关闭该应用程序为止。
Any/all help is appreciated :) 任何/所有帮助表示赞赏:)
I of found out that a small side view had a wrong reference set. 我发现一个小的侧视图具有错误的参考集。 It was 'strong', should have been 'weak' 这是“强”,应该是“弱”
@property (nonatomic, weak) UISomeView * someView;
After that the memory was released normally and did not stack up any more 此后,内存正常释放,不再堆积
tnx @JonathanCicohons for the hint :) tnx @JonathanCicohons的提示:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.