Когда я создаю новый проект и запускаю, весь код:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
память 53M:
![enter image description here](https://i.stack.imgur.com/eNCES.png)
Затем я изменил код:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
for (int i = 0; i < 1000; i ++) {
UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
tableView.backgroundColor = [UIColor redColor];
tableView.userInteractionEnabled = NO;
[self.view addSubview:tableView];
}
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
for (__strong UITableView *tableView in self.view.subviews) {
[tableView removeFromSuperview];
tableView = nil;
}
}
тенденция памяти:
![enter image description here](https://i.stack.imgur.com/2c2qX.png)
До того, как я записал на пленкупредставление, память составляет 117M, после того, как я коснулся представления, все вспомогательные представления удалены, память уменьшилась до 91M.
Почему 91M не 53M?
ПРИМЕЧАНИЕ:Я использую симулятор iPhone X.