How to Understand Android program running performance optimization

Source: Internet
Author: User

I. Use logcat output with caution
If your application always outputs logs in the background. I or log. d content, in addition to increasing system overhead, affects the overall efficiency of your application, especially the continuous output of a lot of content. Because logs require underlying JNI calls, the overhead of Java virtual machines is not small.
Ii. proguard disturbance
For Android app encryption, the disturbing rule may not only modify the name of classes and variables, but also addAlgorithmThe complexity may change from 1 + 1 = 2 to 2*10-10-8. Of course, Android provides an example to illustrate the working principle of the disturbance.ProgramThe running efficiency and some logic may change, so we need to weigh whether the configuration disturbing rule only modifies the variable name.
3. Basic Knowledge
1. Access variables are faster than accessing fields of A Class/
2. When determining whether the array is null, The getcount () = 0 method is generally not used. It can be processed directly using the isempty () method.
3. Use global static classes with caution in many cases.
4. Many of the CPU usage of the Android Application is put on the JVM resources. Therefore, it is helpful to reduce the memory release or increase the mobile phone Ram to execute the program as much as possible.
5. Register as few System broadcast notifications as possible. At the same time, you can rewrite onpause or onresume to control the display of activity to obtain some system broadcasts.

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.