Retain and Realese, nonPointerIsa represents a non-pointer structure. NonPointerIsa is similar to TaggedPointer in terms of position handling. But they are completely different things, and TaggedPointer is the handling of related object types.

You can see the iOS object Exploration three this article, the following is the x86 64-bit system under the ISA bit domain information introduction.

0: pure ISA pointer, 1: isa contains not only the address of the class object, but also the reference count of the object. // Has_ASsoc associated object flag, 0: none, 1: Has_cxx_dtor specifies whether the object has a destructor for C++ or Objc. If it does, the destructor logic needs to be done. If it does not, the object can be freed faster. // Shiftcls stores the value of the class pointer. With pointer optimization turned on, 33 bits are used to store class Pointers in the ARM64 architecture. // magic: Used by the debugger to determine whether the current object is a real object or has no space to initialize. // Weakly_referenced Indicates whether an object is pointed to or has been pointed to an ARC weak variable. Objects without weak references can be released faster. // deallocating: Indicates whether the object is freeing memory. // unused: indicates whether a hash is being used. // has_sideTable_rc: when the object reference count is greater than 10, it needs to be borrowed to store the carry. When representing the reference count value of this object, the reference count value is actually reduced by 1. For example, if the object's reference count is 10, extra_rc is 9. If the reference count is greater than 10, the following has_sideTABLE_rc is used.Copy the code

retain

Retain process summary:

  1. Determine whether or notisTaggedPointertype
  2. Determine whether or notnonpointer

2.3NewISa.bits moves 45 bits to the left and adds one. 2.4NewISa.bits divides the array by 2. Extra_rc stores half the value and the hash table stores half the value. This is done for efficiency, if you save all of them in the hash table, you need to operate the hash table, you need to open the table to look up the table, compare performance.

realese

Realese process summary:

  1. Determine whether or notisTaggedPointertype
  2. Determine whether or notnonpointer

2.3 Decrement extra_rc if it is nonpointer 2.4 Decrement extra_rc if it is out of range. If it is, decrement is a hash. If so, take half the value of the hash table and assign it to extra_RC and update the value of the hash table. 3. Dealloc messages are sent to the extra_rc object when both the value in extra_rc and the hash table are 0, or when there are no hash tables.