,你是否在使用高德地图或百度地图时内存持续上涨而烦恼啊?教你一招搞定它,把缓存清理下就爽多了。当然你内存泄漏了,神也救不了你。
在AppDelegate.m或AppDelegate.mm增加这个代码
- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application { NSLog(@"清除所有缓存"); [[NSURLCache sharedURLCache] removeAllCachedResponses]; }
iphone4手机使用3D地图可能出现内存不足,内存不足时的例子日志如下:
2015/09/06 16:17:56:009 AppDelegate.m:-[AppDelegate applicationDidReceiveMemoryWarning:]:438 Debug:清除所有缓存
2015/09/06 16:18:14:389 MoneyAccountViewController.m:-[MoneyAccountViewController showClass]:138 Debug:函数
2015/09/06 16:18:14:399 MoneyAccountViewController.m:-[MoneyAccountViewController tableView:numberOfRowsInSection:]:88 Debug:函数
2015/09/06 16:18:24:084 MoneyAccountViewController.m:-[MoneyAccountViewController showClass]:138 Debug:函数
2015/09/06 16:18:24:085 MoneyAccountViewController.m:-[MoneyAccountViewController tableView:numberOfRowsInSection:]:88 Debug:函数
2015/09/06 16:18:34:800 AppDelegate.m:-[AppDelegate applicationDidReceiveMemoryWarning:]:438 Debug:清除所有缓存
2015/09/06 16:19:04:968 AppDelegate.m:-[AppDelegate applicationDidReceiveMemoryWarning:]:438 Debug:清除所有缓存
2015/09/06 16:19:20:530 AppDelegate.m:-[AppDelegate applicationDidReceiveMemoryWarning:]:438 Debug:清除所有缓存
2015/09/06 16:19:32:599 AppDelegate.m:-[AppDelegate applicationDidReceiveMemoryWarning:]:438 Debug:清除所有缓存