Check whether the delegate or datasource uses the retain attribute or the assign attribute for Memory leakage.

Source: Internet
Author: User

First, delegate uses the assign attribute instead of the retain attribute.

So why is it assign instead of retain?

In terms of memory management, the lifecycle of the delegate should not be controlled by the object. If the object uses retain, it is likely that the delegate cannot be correctly released.

Specifically, the following link is used:Assign is used to prevent cross-reference.

There are 3 classes .... A .. B .. c .. I am in .. create B... C .... and set C's delegate = self (that is, B ).. if the delegate in C is retain... then the retain of B will be + 2 (Class A is created + 1)
At this time .. if I release B in... then B's retain won't be 0 (because C's delegate is retain )... that is to say, B will never be released .. it cannot be released.

This memory leakage cannot be discovered by instrument.

NextArticleWell written! Let's take a look!


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: 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.