我想在低内存条件下测试我的应用程序。以前,我采用的方法是运行以下命令:
[NSTimer scheduledTimerWithTimeInterval:2.0 target:[UIApplication sharedApplication] selector:@selector(_performMemoryWarning) userInfo:nil repeats:YES];
但是它不再起作用了。所谓的“工作”,是指didReceiveMemoryWarning未被调用。我还尝试过以下方法:
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object: [UIApplication sharedApplication]];
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object: nil];
[[UIApplication sharedApplication] _performMemoryWarning];
但是以上所有方法似乎都无法解决问题。
如果有任何想法,将不胜感激。