Xcode Instruments — Zombies

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:

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Color Animation in SwiftUI

Helpful iOS and Xcode Code Snippets

Top 3 iPhone App Development Latest Features to Watch Out in 2021

Flutter Navigator 2.0 for web dev: Url handling

Jailbreak iPhone 11 Pro iOS 14

GeometryReader in SwiftUI

How to use Tink Link iOS with Expo

iOS Lightweight Hooking Library

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pratheesh Bennet

Pratheesh Bennet

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

More from Medium

Add Touch ID & Face ID in Swift

How To Use UIView as NavigationBar Which Allow You to change NavigationBar Size

BigNav

How to create a new Xcode project without Storyboard ?

Content Hugging & Content Compression Resistance Priority [iOS — CHCR priorities]