OC for iOS Development (12)--memory management arc

Source: Internet
Author: User

(i) automatic memory management--arc

1> simple point is to let the compiler complete the heap space reference count of the addition and subtraction, automatic release, programmers no longer write retain and release methods

2>OC Automatic memory management is different from Java garbage collection, but rather in preprocessing is directly in the place should be kept add retain, where should be released to add release, is directly added code

3> arc outperforms Manual memory management in terms of efficiency

Limitations of 2.1.1 ARC

1> using arc may cause memory to be released prematurely because of code specifications

2> Import third-party libraries, or import old code that does not support arc

2.2 Tips for using arc

2.2.1 Commonly used two keyword-modified references

The __strong (strong Reference) default property, its decorated object pointer, points to which object, retain the object, and the object to which it is being left.

__weak (weak reference) its decorated object pointer, pointing to any object is not retain. The object pointed to by such a pointer may disappear at any time. If the object disappears, the pointer will automatically become nil.

In iOS programming, proxy objects use weak references.

OC for iOS Development (12)--memory management arc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.