我正在创建一个ios应用程序,我启用了ARC模式。 我正在向ScrollView加载24个实例,但在给定时间只显示三个视图。因此,我将删除已加载到内存中的其他不需要的实例
if((NSNull *)[viewControllers objectAtIndex:2] != [NSNull null]) {
[viewControllers replaceObjectAtIndex:2 withObject:[NSNull null]];
[content3.view removeFromSuperview];
//remove third content page
[content3 viewDidUnload];
//set nil to instance to memory management
content3 = nil;
NSLog(@"Content 3 removed");
}
但是当我查看探查器时,内存不会被释放,只会自动增加。
有人可以给我一些关于这个问题的提示吗?
由于
答案 0 :(得分:0)
我认为您的代码中存在很多问题:
viewDidUnload
。永远不要尝试做这些事情,否则你会从你的应用程序中面对奇怪的行为。检查此代码:
if([viewControllers objectAtIndex:2] != [NSNull null])
{
[viewControllers replaceObjectAtIndex:2 withObject:[NSNull null]];
[content3.view removeFromSuperview];
content3 = nil;
NSLog(@"Content 3 removed");
}