OBJECTIVE-C (Memory management)

Source: Internet
Author: User

This paper mainly records the knowledge points of objective-c memory management;

1, Objective-c objects are allocated within the heap, and C Mallock and C + + similar, only int and other system variable allocation within the stack;

2, Objective-c No Java such a complex garbage collection mechanism, it uses a reference count, it can be understood that when the object is created, the pointer to the first address of the object is referenced elsewhere, if the addition of reference number plus one, minus one, and when the reference number is zero the system clears the variable. The internal should be the allocated address on the heap is re-set to valid, that is, it can be assigned to another object, the pointer to store the first address of the object is cleared, like the C language, free (PTR);p tr = null;

3, objective provide retain and release method, call the former reference count plus one, the latter minus one;

4, Objective provides autoreleasepool (auto-free pool) modifier, within this modifier scope, the system helps you maintain the memory allocation and release;

OBJECTIVE-C (Memory management)

Related Article

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.