iOS Learning Summary (iii)

Source: Internet
Author: User

Memory management rules

Get the way

Temporary objects

Owning object

Alloc/new/copy

Releasing objects when they are no longer in use

Releasing an object in the Dealloc method

Any other method

Do not need to take any action

Hold when object is obtained, release object in Dealloc method

Memory Management Rule Summary: 1, release the object, you can free the memory it occupies, the rule is: when you no longer use objects created or persisted, they are freed. 2. Sending a release message does not necessarily destroy the object, only the reference count becomes 0 o'clock to destroy the object. System to

The Dealloc object sends a message to release the memory it occupies. 3. The automatic release pool automatically releases the objects in the pool when releasing the pool itself. The system sends a release to each object

Send a DEALLOC message to the object that the reference count becomes 0 to free the memory it occupies. 4. If you no longer need an object in your method, but need to return it, you can send a autorelease message to add the

The free-moving pool.
5. If using Alloc or Copy method (or using Allocwithzone:, Copywithzone: or Mutablecopy method

To create the object directly, you are responsible for releasing it. Each time you retain an object, you should release or autoreleas it. 6. In addition to the methods mentioned in the rules, it is not your responsibility to release the objects returned by other methods without bother.

iOS Learning Summary (iii)

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.