IOS uses Arc Technology to release memory

Source: Internet
Author: User

Some time ago, I went online to find out how to release the memory. However, you cannot find it. Today, I am continuously testing and viewing the parent window of the view.

Nslog (@ "% @", self. View. superview. superview );

At this time, I found that every page Jump, the parent window and the Child Window of the parent window still exist. If the page Jump continues, and the memory of the useless window is not released, the memory will increase, like a ladder, there will never be an end.

If you don't talk much about it, you should focus on it.

-(Void) viewwilldisappear :( bool) animated {[Super viewwilldisappear: animated]; // stop timer when image hiding if ([Timer isvalid]) {[Timer invalidate];} // nslog (@ "% @", self. view. subviews); // [self. view removefromsuperview]; for (uiview * temp in self. view. subviews) {[temp removefromsuperview];} // --- release the memory --- // set the question array // allthequestions = nil ;}

I release useless pointers before the page is about to disappear. For example, in the code above

Allthequestions is a variable array (nsmutablearray) that stores 40 elements. If the memory of this array is not released before the page Jump, the code above is shown. Use instrument to detect such:

After I release the memory, for example:

The key is to assign a useless pointer to it without nil.

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.