ios-Memory Management Summary

Source: Internet
Author: User

One, garbage collection mechanism (GC garbage collection):

1. The memory used by a system-level thread is automatically checked for the release of useless objects.

2, garbage collection mechanism has multiple different algorithms to implement garbage collection mechanism. But the whole idea is to find useless objects-> Reclaim space occupied by useless objects.

3, the advantages and disadvantages of garbage collection mechanism:

Advantages: Automatically frees up memory, simplifies programming, and improves programming efficiency. Prevents memory leaks and ensures security.

Cons: The JVM must trace the objects that are useful in the program, freeing the useless objects, which takes processor time, and the overhead affects the performance of the program. The advantages and disadvantages of the proposed algorithm have a great impact on the efficiency of garbage collection.

Second, arc (Automatic Reference counting automatic reference count)

1, in short, is the code automatically added to the Retain/release, the original need to manually add the reference count to handle memory management of the code can be automatically completed by the compiler.

2. ARC is not a GC, it is just a static analyzer tool for code.

Iii. MRC (Manual Reference Counting manual reference count)

1, when the Retaincount is zero, will automatically call the object's Dealloc method for memory release recovery, we should never manually call the object's Dealloc method.

Iv. Initialization issues

1. New and Alloc/init are almost identical in function, allocating memory and completing initialization. The difference is that the new method can only be initialized with the default Init method, which is used in a alloc way, with other custom initialization methods.

2, Alloc when the object memory size configuration, the size of the memory by the object's properties, instance variables, methods of memory address synthesis. Alloc is simply the configuration of the address memory for variables and methods, and the exact size of the attributes and variables is dynamically non-matching at init time.

  

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.