This is the 15th day of my participation in the August More Text Challenge

The zombie object

An object that has been destroyed is called a zombie object.


Wild pointer

  • When a pointer points to a zombie object, we call it a wild pointer
  • An error is reported whenever a message is sent to a wild pointer

Null pointer

  • No pointer to storage (nil, 0)

  • To avoid errors when sending a message to a wild pointer, we typically set the pointer to an object to null when it is released

    Note: In OC, sending a message to a null pointer is not an error


Debug memory management problems with zombie objects

  • Memory problems cause programs to occasionally crash. Why?

    The root cause of the problem depends on whether the memory occupied by the object has been overwritten by something else, and whether the memory has been diverted to other uses is uncertain, causing the program to crash occasionally.

  • Zombie object best way to debug memory management problems

    In iOS, zombie debugging is provided. If you enable this debugging function, if there is a memory management problem, the runtime system will recycle all the problem instances into special “zombie objects”, without actually recycling them. Zombie objects will throw an exception when they receive the message. The ability to accurately describe incoming messages and objects before recycling.

  • To enable debugging:

  • For example

    • Zombie object debugging is not enabled

    • Enable “zombie object” debugging (there will be a message)


IOS Memory management

  • Memory management in iOS (Basic Concepts)
  • Memory Management in iOS (reference counters)
  • Memory Management (ARC) in iOS
  • Memory management in iOS (Autoreleasepool)
  • Memory Management in iOS (Zombie Objects)