I'm working on an iPhone app, and I got this strange log sometimes when manipulating a map:
ImageIO_Free: ptr 开发者_如何学Python0xdf0f000 got double released??? (16384 bytes)
If I countinue playing around, the app would crash. I googled it, but haven't found anything interesting... So weird !
There is a single thread on the Apple Developer forums that sheds some more light on this: "Map kit related crash?"
The individual who responded to the post has much more detailed diagnostic information and it shows that the crash is happening in a separate thread, yet he is not spawning any threads that could result in the behavior / crash he's getting.
You should file a bug with Apple.
Without my crystal ball I can only guess, but you probable release
d something manually that was already marked for autorelease
.
Read the Memory Management Programming Guide, especially the Memory Management Rules! Twice.
It's most likely a warning that the same object has sent the ImageIO_Free object one more release than it sent an explicit or implicit retain. ImageIO_Free is over released and subsequently dies unexpectedly causing the crash.
This just happened to me and I believe I have the answer.
The problem seems to be with adding annotations to a map view. It seems that when you call "addAnnotations" on a MKMapView instance, the MKMapView object does not retain those objects. So after you play around with the map, and move the annotations in and out of view, when it comes time to re-render the annotations, the memory has been released, and you get a EXC_BAD_ACCESS error.
To solve this, just retain the objects to add as annotations. This can be accomplished by having a NSMutableArray instance variable of the maps current annotations. Every time you call addAnnotations, also add those objects to this retained array and you should be all set.
In your .h file:
@interface MapViewController : TTModelViewController <MKMapViewDelegate, UIAlertViewDelegate> {
NSMutableArray *feeds;
}
@property (nonatomic, retain) NSMutableArray *feeds;
In your .m file:
@synthesize feeds;
// (release feeds in your dealloc)
And when you're adding annotations, do something like this:
if (self.feeds == nil) {
self.feeds = [NSMutableArray array];
}
[self.feeds addObjectsFromArray:newPois]; // newPois is an array of annotations
[mapView addAnnotations:newPois];
Working for me so far. Will update if things change. If you remove objects from the map view, you'll probably also want to keep this feeds array in sync, to avoid "dead memory."
精彩评论