【发布时间】:2014-01-05 13:06:58
【问题描述】:
说明
我的应用程序仅使用 35-70mb,有时在报告中被 35mb 杀死。原因总是 vm-pageshortage
- 从任何地图视图转到相机(重复 N 次。在具有大量可用 RAM 的设备上当然需要更长的时间)
- 您将开始(很快(!)接收内存警告
- BOOM(被杀)
这适用于任何使用 MKMapKit 或 GoogleMaps 的应用程序。我想这与一些没有出现在仪器中但在虚拟机中的图形数据有关。 这在 IOS6 中没有发生
带有演示代码的 GMS Bug Tracker 问题
https://code.google.com/p/gmaps-api-issues/issues/detail?id=6209&thanks=6209&ts=1388925382)
问题 1
我在我这边释放对象就好了,我看到 dealloc 被正确调用了。 => 我能以某种方式影响 MapKit / GoogleMaps 以释放 VM 空间吗?
问题 2
奇怪的是,根据报告,系统上还有更大的应用程序,但我们的却被杀死了: => whatchdog 中是否有一些机制更喜欢在 appstore 应用程序之前杀死 DEBUG(或者可能是非 appstore)应用程序?
示例项目: 只有 1 个视图控制器,只有 1 个地图(通过 Apple MapKit,GMS 也同样糟糕),推动相机并拍照 --- BOOM
可运行代码:https://dl.dropboxusercontent.com/u/3753090/MapKitTest.zip
- (void)loadView {
UIView *v = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CGRect f = v.bounds;
mapView = [[MKMapView alloc] initWithFrame:CGRectInset(f, 5, 5)];
[v addSubview:mapView];
self.view = v;
}
- (void)viewDidAppear:(BOOL)animated {
[self performSelector:@selector(delayed) withObject:nil afterDelay:3];
}
- (void)delayed {
UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = (id)self;
imagePickerController.showsCameraControls = NO;
[self presentViewController:imagePickerController animated:YES completion:nil];
[imagePickerController performSelector:@selector(takePicture) withObject:nil afterDelay:2];
}
- (void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *jpg = UIImageJPEGRepresentation(image, 0.8);
NSLog(@"jpg %d", ((const char*)jpg.bytes)[0]);
[self dismissViewControllerAnimated:YES completion:nil];
}
仪器截图:
https://www.dropbox.com/s/v1v5ll8v5kjt7ev/Screenshot%202014-01-05%2021.00.58.png
和报告:
https://dl.dropboxusercontent.com/u/3753090/report%2005-01-14%2021-00.crash
【问题讨论】:
-
能否在您的问题中添加代码,以便我们更好地理解问题?
-
顺便说一句,这篇文章liam.flookes.com/wp/2012/05/03/finding-ios-memory 很有趣。它没有帮助,但它可以帮助你看到你失去记忆的地方
-
提交了雷达 (15750089) - 因为即使使用最小的应用程序也可以 100% 重现 - 有时更快有时更晚
-
我测试了你的代码,它仍然可以处理 30 多张图片,并且内存保持不变
-
添加了演示+报告+截图
标签: ios memory-management mapkit google-maps-sdk-ios