ARC + Zombie Objects broken

Today I got bitten by a bad iOS bug.
With ARC enabled and also Zombie Objects enabled, dealloc of a View might never be called!
For details see:
http://openradar.appspot.com/10537635
Also very interesting:
http://stackoverflow.com/questions/8408071/why-is-object-not-dealloced-when-using-arc-nszombieenabled
at least the original post. The answers are rather confusing though …

So my incarnation of the bug goes as follows….
On my core data based app, if a user logs in, I cleanly open the user’s persistent store.
If the user logs out again, I’ll do the logging out in the background. This keeps the persistent store referenced until the logging out is done.
Now, if the same user logs in again I’ll wait with a spinner until the persistent store is released before I open the store again with a new persistent store coordinator.

Now most of the app is non-ARC. Just one component (GMGridView) is ARC enabled.
When I compile the app with zombies objects enabled, on logout the (flawless) GMGridView component is correctly released and deallocated but ARC does not decrement the retain count of the (non-ARC) GMGridViewCells to 0. The cells dealloc is never called, it does not release it’s reference to the store and the next login will wait forever.
Disabling zombie object fixes the problem!
Googling for this issue suggests that this is fixed in iOS 6.

Took me three evenings to find out that this was related to zombie objects

One thought on “ARC + Zombie Objects broken

  1. Hi! I could have sworn I’ve been to this blog before but after checking through some of the post I realized it’s new to me. Nonetheless, I’m definitely delighted I found it and I’ll be book-marking and checking back often!

Leave a Reply

Your email address will not be published. Required fields are marked *


five − = 0

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>