Tips for solving arc Memory leakage and arc Memory leakage

Source: Internet
Author: User

Tips for solving arc Memory leakage and arc Memory leakage

Be sure to note that when running the app, We must care about the memory usage and try not to exceed20 M,Even if many images are to be displayed, they cannot exceed30 M. Therefore, it is a good habit to focus more on memory usage when running apps developed by myself.

For performance and memory optimization, this involves too much. Now let's talk about several common solutions to memory leakage.

 

1. instruments

Instrument can report a lot of memory leakage errors. The method is http://www.cocoachina.com/ios/20141203/10519.html, which is easy to operate.

However, its biggest function is to see where the memory is used more and optimize it.

2. arc Problems

ARC does not manage C-types, of which CGImage may be considered. You must release the ref manually when you are finishedCGImageRelease (image );

This is the answer from stackoverflow, that is, in arc mode, the C-types object needs to be manually released.

 

Arc also has issues such as loop reference, which prevents objects from being released. You can write-(void) dealloc to set breakpoints. If the page does not jump, this proves that you have made a mistake. If the automatic count is not 0, it will not be released, the memory will continue to increase, and you need to find the error.

3. image suggestions

Many images need to be loaded. Do not store images in the queue. Either the image exists in the sandbox, the address in the queue, or the thumbnails in the queue are stored. Click the image and zoom in again.

The most undesirable method is to have a clear big image. You may need to reduce the size of the Image view, which is very memory-consuming.

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.