iOS视图控制器内存在被解除后未释放

Chr*_*nam 7 memory objective-c ios automatic-ref-counting

当用户单击按钮时,它会显示一个带有两个视图控制器的新标签栏视图控制器.我就是这样做的

ACLevelDownloadController *dvc = [[ACLevelDownloadController alloc] initWithNibName:@"ACLevelDownloadController" bundle:[NSBundle mainBundle]];
ACInstalledLevelsController *ivc = [[ACInstalledLevelsController alloc] initWithNibName:@"ACInstalledLevelsController" bundle:[NSBundle mainBundle]];
UITabBarController *control = [[UITabBarController alloc] init];
control.viewControllers = @[dvc, ivc];
dvc.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:0];
ivc.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:1];
[self presentViewController:control animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

这很好用.我关闭那些视图控制器具有dismiss在两个方法ACLevelDownloadControllerACInstalledLevelsController.这也很好.奇怪的是,当我呈现视图控制器时,内存使用率会上升 在此输入图像描述

但它永远不会失败.如果我再次呈现它,它会更上升 在此输入图像描述 我正在使用ARC.为什么视图控制器使用的内存在被解除后不被释放?

编辑

他们被解雇的方式是两者ACLevelDownloadController并且ACInstalledLevelsController已经连接了IBActions,当他们被点击时调用这个方法

- (void)dismiss:(id)sender{
    [self dismissViewControllerAnimated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

Mee*_*era 4

从内存使用图中我们可以观察到 tabViewController 没有被正确关闭并且它在堆栈中累积。关闭时,您必须允许呈现 tabViewController 的 viewController 关闭它。解雇是其责任。还要保留 Outlets 的弱引用,并将任何强引用分配给viewWillDisapper:中的 nil** 。您可以以模态方式呈现 viewController 作为临时中断,以从用户那里获取重要信息。如果不是这种情况,您可以删除模态呈现。检查此链接。希望这可以帮助 :)