didReceiveMemoryWarning
应该包含哪些内容?我没有看到任何可以释放的东西仍在记忆中。我为managedObjectContext
设置了一个属性,就是ivars。
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *calendar = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"calendar.png"]style:UIBarButtonItemStyleBordered target:self action:@selector(viewCal)];
self.navigationItem.rightBarButtonItem = calendar;
[calendar release];
UIBarButtonItem *settings = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"gears.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(viewSettings)];
self.navigationItem.leftBarButtonItem = settings;
[settings release];
[SHK flushOfflineQueue];
[self clearNullWorkouts];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
答案 0 :(得分:2)
什么在SHK中使您成为flushOfflineQueue以及clearNullWorkouts做什么?这些可能是您在didReceiveMemoryWarning
期间需要释放的资源。也只是因为didReceiveMemoryWarning
触发并不意味着你必须清理任何东西,例如,如果你仍然显示视图,播放正被引用的音频文件等等。当这个被调用你需要释放像未显示的图像,未播放的音频等。调用didReceiveMemoryWarning
后,未显示的视图控制器将调用viewDidUnload
,您将在此处设置所有IBOutlets / programmatic视图为nil并释放更多内存。 Apple在Memory Management Programming Guide中讨论了这个问题。