Results of IOS sending messages to objects that have been released

Source: Internet
Author: User
    NSObject *object = [[NSObject alloc] init];
    NSLog (@ "release before = = =%lu", [object Retaincount]);
    [Object release];
    NSLog (@ "after release = = =%lu", [object Retaincount]);
    Print results in two cases
    /*
     1. Direct crash: Cause the memory of the object is reused.
     2. Before the release = = 1
       released = = 1
       reason: When the last time the release, the system knows that the immediate recovery of memory, there is no need to reduce the Retaincount 1, because no matter minus 1, the object will certainly be recycled, and the object is recycled, Its memory area, including the Retaincount value, also becomes meaningless. Not minus 1. Can reduce the operation of the memory once, accelerate the collection of objects.
     */


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.