views:

517

answers:

6

I'm working on an iPhone app, and I got this strange log sometimes when manipulating a map:

ImageIO_Free: ptr 0xdf0f000 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 !

A: 

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.

TechZen
+1  A: 

Without my crystal ball I can only guess, but you probable released something manually that was already marked for autorelease.

Read the Memory Management Programming Guide, especially the Memory Management Rules! Twice.

hop
Well, it was one of the first thing I had thought about. I've checked out my code twice, no double release...The strange thing is that it only happens from time to time.I also have some MKPinAnnotationView objects on the map.
d_o_p
it only happening intermittantly probably means that there is a racing condition. anyway, your error message tells us there is a double release, you give us nothing more to work with. what do you expect?
hop
Yeah, I know, but the problem happens even with a simple MKMapView view without anything else. I tried by creating a new file with associated .XIB, added a MKMapView, played around with the map and got the same error. So I was wondering if it was a problem related to the framework and if anybody else has faced the same issue.
d_o_p
Your advise seemed to solve the issue for me. I have a CLLocation that I used to release right after zooming to it. As soon as I commented out the [currentLocation release] statement, it stopped throwing EXC_BAD_ACCESS with ^^ that message.
Elijah
A: 

I've got this problem randomly also...

ImageIO_Free: ptr 0xd700000 got double released??? (16384 bytes) hash: 0

Don't know how to fix. Seems to be a problem with the framework.

dwidman
+3  A: 

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.

Tegeril
A: 

Same problem here. File a bug at bugreport.apple.com.

Nikolai Ruhe
A: 

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."

Jared Egan