简体   繁体   English

模态呈现的UIViewController在关闭时不会清空内存

[英]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 have a viewcontroller that displays some data 我有一个显示一些数据的ViewController
  • when a user clicks a button another view controller is presented modally 当用户单击按钮时,将以模态方式显示另一个视图控制器
  • after the user closes the modal controller, the memory usage does not decrease 用户关闭模式控制器后,内存使用量不会减少

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.

相关问题 `SwiftUI` - `EnvironmentObject`s,`EnvironmentValues` 不会传播到模态呈现的 `UIViewController` - `SwiftUI` - `EnvironmentObject`s, `EnvironmentValues` does not propagate to modally presented `UIViewController` 确定是否以模态方式呈现UIViewController - Determining if a UIViewController is being presented modally 呈现的UIViewController模态显示移到顶部 - UIViewController presented modally show up shifted to the top 获取最高的 UIViewController(如果以模态方式呈现) - Get top most UIViewController if its presented modally 以模态呈现的UIViewController的背景颜色随机变化 - Background Color Randomly Changes of UIViewController presented Modally 在iOS7上模态显示时,以前的UIViewController会流血 - Previous UIViewController bleeds through when presented modally on iOS7 使用选项UIModalPresentationOverCurrentContext减少以模态方式呈现的uiviewcontroller的帧大小 - Reducing the frame size of a uiviewcontroller being presented modally with option UIModalPresentationOverCurrentContext 有没有办法知道UIViewController是否已经以模态方式呈现和解散? - Is there a way to know if a UIViewController has been presented and dismissed modally ? 在以模态显示的UIViewController中使用UITableView时的奇怪行为 - Odd behaviour when using UITableView in a UIViewController that is presented Modally 如何以模态方式呈现的UIViewController的UIView总是出现在屏幕的底部? - How to have a UIView of a UIViewController that will be presented modally always be present at the bottom of the screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM