Clicky

iOS Dev Nugget 255 Symbolic Breakpoint to watch for View Controller Deallocation

.

Need to run a code review on your codebase? Hire me

One of the easiest ways to start hunting down memory leaks is to see if a view controller is not being deallocated. Most common reason being an object stored in an instance variable is (in)directly holding a reference the view controller.

Here's a tip I picked up from @0xced:

Create an Xcode symbolic breakpoint and set the following values:

  • Symbol: -[UIViewController dealloc]
  • Add an Action: Log Message
  • Action value: --- dealloc @(id)[$arg1 description]@ @(id)[$arg1 title]@
  • Add another Action: Sound
  • Sound: Choose a sound

If you pop or dismiss a view controller and don't hear the sound, there's a leak.

Thanks @0xced!

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues