When does ARC launch in the life cycle of an iOS application?

ARC is used in iOS, and the object will be automatically freed if the reference count is 0. In the quick-book example, the code sets some var to nil to make the reference count equal to 0. In the current iOS application, I may not intentionally set that- then zero to free up memory if the object is really large.

My question is, when will release in ARC occur in the application life cycle? I consider two cases:

  • If we move from one view manager to the next view manager, will the first view manager be automatically freed? Suppose we do not save a copy in the next view manager.

  • If iOS somehow just killed our application, let's say it needs memory or something else, will it just clear all the memory used by our application? Or will he set something to zero and run ARC to finish the job? If there is some strong reference cycle in the code, will there be a memory leak in this case?

+4
source share
2 answers
  • It has already been answered here that the first view controller will not be released if it pushes / represents another controller.
  • iOS , , , . , , . -, , . . didReceiveMemoryWarning . .
+1

, , , , .

, , -, .

+1

Source: https://habr.com/ru/post/1599351/


All Articles