Viewcontroller release in IOS memory

Source: Internet
Author: User

In program development, it is common to use Viewcontroller. But sometimes because of improper use, it can not be automatically recycled, causing some hidden bugs. or from a coding point of view, it makes people feel uncomfortable. Because some things in memory are not cleanup.

Here are a few things:


1) Three cases of self release from Viewcontroller
1.1 Delegate No empty nil
1.2 Block loop Reference, you should use weakself in block to refer to: __weak typeof (self) weakself = self;
1.3 Nstimer must first stop (invalidate) and then nil off.

2) [Controller.view Removefromsuperview]; Remove yourself from the parent control, reference-1


3) Controller.view = nil; Release view


4) controller = nil; Release Viewcontroller

Viewcontroller release in IOS memory

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.