ios-Non-ARC Project memory management details (actual combat)

Source: Internet
Author: User

1. Preface

Next: ios-How to convert a non-ARC project into an arc project (actual combat)

2. Memory-management-related configuration

When we manage the non-arc memory management, we find that when doing some operations memory is still slowly increased such as the simplest random number uitableview display and sliding, memory management, should not appear memory increase, However, the sliding memory has been slow to increase the upward situation.

At this point we can check to see if the properties here tick:

or detect if the console does not immediately output the following phrase when the app is started

If the above three options are checked, the console will show the following lines of output

arctest (651,0X1F321A8) malloc:stack logs being written into/tmp/stack-logs.651.8af7000.arctest.jgqgod.index arctest (651,0x1f321a8) malloc:recording malloc and VM allocation stacks to disk using standard recorder

If found, remove the three attributes of Figure 1. These three options as long as the user is constantly operating, the program will record something, this time will consume a certain amount of memory.

3. Memory Management Methods

3.1. In non-ARC environments, all class methods

In non-ARC environments, all class methods are initialized

The system will not help you manage memory.

And you have no effect on direct release.

Memory will still increase until the crash/ This release is wrong, without effect, and the memory will continue to increase:
     while (true) {        Nsmutablearray *arr = [Nsmutablearray array];        [arr release];    }

the correct class method memory management should be:

Correct Memory Trend Chart:

3.2. And if it is init initialization method
   while (true) {        nsstring *re = [[NSString alloc] initwithformat:@ "ddd"];        [Re release];    }
We release the memory correctly by manually releasing it once. This is the difference between the memory management of class initialization and INIT initialization in non-arc classes. because previously saw a post on the Internet that the class initialization does not require user manual management, so he did a test. It's not working in a non-arc.

Clear Saup
Source: http://www.cnblogs.com/qingche/
This article is copyright to the author and the blog Park is shared, welcome reprint, but must retain this paragraph statement, and in the article page obvious location to give the original text connection.

ios-Non-ARC Project memory management details (actual combat)

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.