我在使用 Instruments 查找内存泄漏时遇到问题。通常它对我有很大帮助,我能够找到泄漏点,但在这种情况下我迷失了。
我正在创建一个 View Controller 来控制从 NIB 文件加载的 View 。该 View 具有“显示用户位置”为 true 的 map View 。找到用户位置后,我使用 MKReverseGeocoder 来获取位置数据。当我加载此 View Controller 并且 MapKit 找到用户位置时,泄漏始终存在。我发现 MKReverseGeocoder 在这里不是问题,因为无论有没有 MKReverseGeocoder,我都会遇到相同的泄漏。
当我加载此 View 时,仪器“泄漏”报告内存泄漏。请参阅图像上的屏幕截图:
这就是我初始化 Controller 的方式:
AddPlaceViewController *addPlaceVC = [[AddPlaceViewController alloc] initWithNibName:@"AddPlaceViewController" bundle:[NSBundle mainBundle]];
addPlaceVC.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addPlaceVC];
self.placeController = navigationController;
[self presentModalViewController:self.placeController animated:YES];
[addPlaceVC release];
[navigationController release];
这一切都在 iPhone Simulator 4 和目标操作系统 3.2 上。
这实际上是泄漏还是我在这里面临的问题?
最佳答案
由于负责的库是“Foundation”而不是您的代码,因此您对此无能为力(除了向 Apple 报告之外)。
关于iphone - 使用 iPhone 应用程序中的 Instruments 跟踪内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3279950/