Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios dissmiss viewcontroller,内存不为';他没有被释放。_Ios - Fatal编程技术网

Ios dissmiss viewcontroller,内存不为';他没有被释放。

Ios dissmiss viewcontroller,内存不为';他没有被释放。,ios,Ios,我有两个ViewController,一个是FirstViewController,另一个是SecondViewController,我使用故事板创建了这两个。在FirstViewController中,有一个指向SecondViewController的按钮 - (IBAction)click:(UIButton *)sender { SecondViewController *secondController = [self.storyboard instantiateViewControl

我有两个ViewController,一个是FirstViewController,另一个是SecondViewController,我使用故事板创建了这两个。在FirstViewController中,有一个指向SecondViewController的按钮

- (IBAction)click:(UIButton *)sender {
SecondViewController *secondController = [self.storyboard instantiateViewControllerWithIdentifier:@"second"];
[self presentViewController:secondController animated:YES completion:nil];
secondController = nil;}
在SecondViewController中,有一个webview

@property (weak, nonatomic) IBOutlet UIWebView *webview


- (void)viewDidLoad{
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webview loadRequest:request];}
还有一个按钮,点击它可以关闭SecondViewController

- (IBAction)click:(UIButton *)sender {
[self dismissViewControllerAnimated:YES completion:nil];}
我的问题

当我在FirstViewController中时,内存是9.1M,然后转到SecondViewController,内存增加到36.8M,然后关闭secondiewcontroller,内存返回到24.8M。 虽然我向secondiewcontroller添加了以下代码,但似乎没有什么帮助

- (void) dealloc{
[self.webview removeFromSuperview];
self.webview = nil;}

我只是想最好地了解如何使用最少的内存。有人能告诉我,在我关闭secondviewcontroller(释放其所有内存)后,如何将内存恢复到9.1M吗?

关闭view controller时是否调用了
dealoc
方法?如果没有,您可能有一个引用周期。您是否尝试过“泄漏”工具?如果来回多次,内存使用是否持续增加?尝试[self.presentingViewController dismissViewController…]@rmaddy是的,将调用delloc方法。