在 mapView 上更新 GPS 指示器的位置...
[mapView removeAnnotation:myGpsAnnotation];
[myGpsAnnotation release];
myGpsAnnotation = nil;
myGpsAnnotation = [[MapLocationAnnotation alloc] initWithCoordinate:region.center annotationType:MapAnnotationTypeGps title:MAP_ANNOTATION_TYPE_GPS];
[mapView addAnnotation:myGpsAnnotation];
...我看到仪器(模拟器)中的净内存在缓慢攀升。没有“泄漏”信号,但“Net Bytes”和“#Net”缓慢增加......除非这段代码被注释掉。所以我 100% 确定这是有问题的代码。
但是,如果我执行以下操作...
[mapView removeAnnotation:myGpsAnnotation];
[myGpsAnnotation release];
myGpsAnnotation = nil;
myGpsAnnotation = [[MapLocationAnnotation alloc] initWithCoordinate:region.center annotationType:MapAnnotationTypeGps title:MAP_ANNOTATION_TYPE_GPS];
[mapView addAnnotation:myGpsAnnotation];
[mapView removeAnnotation:myGpsAnnotation];
[mapView addAnnotation:myGpsAnnotation];
[mapView removeAnnotation:myGpsAnnotation];
[mapView addAnnotation:myGpsAnnotation];
...然后“Net Bytes”和“#Net”增长得更快。这可能不是我的错误,我正在尝试追踪 MapKit 中的泄漏吗?我真的在泄漏内存吗?同样,“泄漏”下什么也没有出现,但我不明白为什么净值会不断攀升。
感谢您的帮助,-戈德