1. Reference counting
What are reference counts,
Reference counting can effectively manage the object life cycle, it can help us to record how many pointers an object has, and make good memory management!!
Example:
Suppose in an office there is only one lighting equipment, the first person to enter the work to turn on the lights, and then continue to come in two people, if we do not remember how many people in the office now, and the first person to leave the lights directly off, will lead to another two people do not have lighting, do not work!!
So the reference count is to record these people, the office is still how many people, if someone is still lighting, until no one's time to turn off the lights!! This can be when someone does not have the problem of lighting, thus doing a better job!!
Do not send a message to an object that has already been disposed
If a message is sent to a disposed object: Sometimes the program crashes, and the program crashes when the memory occupied by the object is reused.
Circular references:
One using the weak one uses the strong problem:
{
Now there are two objects of A and B
Then a holds object B, B holds a
Because object A's destruction relies on object B's destruction, and Object B relies on the destruction of object A, even if there are no pointers to them outside, they cannot be freed, causing a strong reference loop to use weak references on a reasonable side.
}
Just in the arc we don't need to manage these problems manually, because the system will help us to release them when they need to be released!!
iOS Development Advanced (iOS Development Combat: Understanding memory Management) Summary