[Super Dealloc] sequence of memory releases

Source: Internet
Author: User
The most headache in objective-c language is memory release, declare a variable to be sure to release this variable, I believe many people in the Dealloc function [super Dealloc] position this problem tangled, after practice found, [super Dealloc] Crash is often written in memory before it is released, but not after it has been written. Yes, objective-c can not write their own release within the [Super Dealloc], because "every class you create is inherited from the parent class, the root class, there are many instance variables will inherit, this part of the variable is sometimes used within your program, They don't automatically free up memory, you need to call the parent class's Dealloc method to release it, but before you do, you need to first release the variable memory in your class, or it will cause a memory backlog in your class, causing a leak. "  Of course, if you use arc after iOS6.0, you will not encounter this problem. The wrong wording ******

-(void) dealloc

{

[Super Dealloc];

[XXX release];

......

}

The correct wording *******

-(void) dealloc

{

[XXX release];

[Super Dealloc];

......

}

[Super Dealloc] sequence of memory releases

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.