Saturday, August 18, 2012

Debugging with ARC and Zombies enabled

If you tried to debug your app with zombies enabled under ARC, you may have noticed that you don’t get zombies anymore. That’s most probably because of a bug in the Foundation framework that affects iOS 5 and OS X 10.7. This bug prevents ARC from "cleaning up" instance variables at deallocation-time according to Apple Technical Q&A QA1758. Apple strongly encourages you to run your app on an iOS 6+, or OS X 10.8+ system when debugging with Zombies.
In the meantime, you can workaround this bug if you are using ARC and trying to debug zombies on older systems. Just compile this NSObject+ARCZombie.m file in your project and ivars will be automatically deallocated under ARC when zombies are enabled, as it should be.
Now you might think Hey, you are swizzling dealloc, isn't that dangerous? Well, yes it is, but note that the dealloc method is only swizzled when the NSZombieEnabled environment variable is enabled, so even if this code slips in your release build, il will cause no harm at all.

UPDATE: After I posted this, Greg Parker warned me on twitter:

@0xced That'll cause over-release of associated objects on some systems.

So use this workaround with care and remember that the best solution is what Apple recommends: run your app on an iOS 6+ or OS X 10.8+ system when debugging with Zombies.

8 comments:

ark console commands said...

In you say that the image view is also strongly referenced by the view controller, hence it won't be deallocated. However, as clearly shown in ImageViewViewController, the image view outlet is a weak reference. How come?



xcom 2 cheats said...

In 23:30 you say that the image view is also strongly referenced by the view controller, hence it won't be deallocated. However, as clearly shown in ImageViewViewController, the image view outlet is a weak reference. How come?


why do chia seeds gel said...

thx for posting this! animals are so rare now in alpha 16, I FINALLY found a stag and killed it then I lagged and selected my club instead of my knife and hit the carcass and it disappeared so I had to spawn in a new one I couldn't let that go :P


ck2-commands said...

thx for posting this! animals are so rare now in alpha 16, I FINALLY found a stag and killed it then I lagged and selected my club instead of my knife and hit the carcass and it disappeared so I had to spawn in a new one I couldn't let that go :P


trafficlogix said...

Good to see this: "Our smart solutions improve safety and prevent accidents at entryways, in facilities and on roadways of all kinds." radar feedback signs, radar trailers, radar speed display signs.

Joker388 said...

Joker388 game terbaik indonesia

Eirin Khoudia said...

Situs IDN Poker Indonesia merupakan situs resmi dari Developer terbesar di Asia yang ditunjuk sebagai salah satu situs terbaik di Indonesia yakni Pokervit.
Menyediakan Promo IDN Poker 2021 Menarik :
1. Bonus New Member 20%
2. Bonus Turnover Harian 3,5JT
3. Bonus Turnover Mingguan 0,5%
4. Bonus Refferal 10%
5. Menyediakan APK IDN Poker Indonesia 2021 Terbaru

Daftar IDN Poker Indonesia
Login IDN Poker Indonesia
Deposit IDN Poker Indonesia
Download IDN Poker Indonesia
Aplikasi IDN Poker Indonesia
APK IDN Poker Indonesia

IDN Poker Indonesia

Yurisa Lin said...

APK IDNPlay Deposit Pulsa 10rb Tanpa Potongan, kini sudah tersedia dan bisa kamu akses dengan mudah hanya dengan menggunakan 1 user id resmi IDN Poker Terbaru yakni Pokervit.

Dengan menggunakan APK IDNPlay IDN Poker 2021, Kamu sudah bisa mengakses semua jenis permainan idn yang sudah tersedia. Dengan minimal betting dimulai dari Rp 1.000 sampai Rp 5.000.

Tidak hanya itu saja, kamu juga berkesempatan untuk mendapatkan bonus new member 20%, Bonus Rollingan Harian, Bonus Rollingan Mingguan, dan Bonus Refferal 10% yang berlaku seumur hidup.

APK IDNPlay
Download APK IDNPlay

APK IDNPlay