Xcode Instruments — Zombies

Pratheesh Bennet
3 min readNov 26, 2018

--

Here I would like to share my experience in successfully solving out a crash while playing around with core data entities using xcode instruments.

The implementation is straight forward. I have one entity “MyApp”, having one attribute “newName”. In viewWillAppear I just create the entity, assign a value to the attribute, do a save and finally do a fetch.

Things were fine until save. But when I printed the fetched result , the THING happened. A crash….

This was all I got. No console logs, no warnings, no murder weapons.

Let’s solve the exception. Yeaaaahhhhhhh…

The initial clues were EXC_BAD_ACCESS and EXC_1386, indicating the presence of it, yes, the ZOMBIE. Zombies are objects having retain count 0 still continuing to exist. To confirm it enable zombies in product -> Edit Schemes -> Diagnostics , enable the check mark for Zombie objects.

Enabling Zombie Logs

Running the app again, I got the logs. Cause of crash due to a string zombie object.

It’s time to find the zombie.

Hi there, I’m zombie

In order to dig deeper we need the help of detective “xcode instruments”. Open xcode ->developer tools -> instruments -> select zombie

Zombies in instruments

Select the desired simulator and app in the scheme and tap the red record button.

Running zombies in instruments

Boom we get this zombie found pop up,

String Zombie object

Seeing the allocation history, I could find that after the fetch, accessing the attribute “newName” caused the memory release of the property,

But why ? what’s the motive ?

https://developer.apple.com/library/archive/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011226

ARC imposes a constraint on method naming:

  • You cannot give an accessor a name that begins with new.

Case is solved, renaming the attribute of the core data entity from “newName” to “updatedName “solved the crash.

Hope this helps you. Any help feel free to reach me at pratheesh_db@hotmail.com.

See related:

--

--

Pratheesh Bennet
Pratheesh Bennet

Written by Pratheesh Bennet

Product owner Falcon Forms (www.falconforms.app). Digitize your paperwork using Falcon Forms. Build and configure your own forms in an instant.