How to handle memory warnings before and after IOS6

Source: Internet
Author: User

here is an article that explains in detail how memory warnings are handled before and after IOS6: Technical Blog from Tang Qiao:http://blog.devtang.com/blog/2013/05/18/goodbye-viewdidunload/
1, iOS4, and iOS5, when a memory warning is received, the system automatically calls the Viewdidunload method that does not currently have a VC on the interface. write the following code in Viewdidunload:
if ([self isviewloaded] &&![ [Self view] (window]) {        [self setview:nil];    }
2, IOS6 began, Viewdidunload was discarded. In the development documentation, Apple recommends moving memory-collection operations to didreceivememorywarning. What else can you write down in didreceivememorywarning to reclaim memory? The best answer is that nothing is written, only the corresponding method of the parent class is called!
3. Briefly explain why IOS6 does not set the VC's view property to nil in didreceivememorywarning. UIView has a Calayer member variable that is responsible for managing the UIView drawing. Calayer is a container class for bitmap images, and Calayer creates this bitmap image class when UIView calls DrawRect. And the majority of a uiview occupies memory is this bitmap image class. Therefore, IOS6 automatically reclaims the bitmap image class when the system issues a memory warning, but does not reclaim the UIView and Calayer classes.


How to handle memory warnings before and after IOS6

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.