Android Application Performance Tuning - "Scheme" to be improved

ANR occurs during the use of the app. This is a painful phenomenon. The app freezes, black screen appears, etc.

1. Optimization direction

insert image description here

  • The direction is the goal: fast, stable, economical and small.
  • The main problems to be solved: Stuck, unreasonable memory usage, poor code quality, messy code logic, and too large installation package, these are the most common problems encountered during the development process.
  • analysis of idea
     1、
    

2. Implement optimization

1. Go to Caton

insert image description here

- UI freeze

- reason

```
-----主要以下两点-----
 - 1、绘制任务太重,绘制一帧内容耗时太长
 - 2、主线程太忙, 主线程做了太多的事情,或有耗时动作。
 ```
  • Main thread responsibilities: interface life cycle control, system event processing, message processing, interface layout, interface drawing, interface refresh.

  • The cooperation between the human eye and the brain cannot perceive the picture update exceeding 60fps;

  • The performance standard of the App is to guarantee the value of 60fps, which means that each frame only takes 1000/60 = 16ms;

  • The interface will be stuck and not smooth, because the current UI processing of this interface exceeds 16ms, and it will take up the next 16ms, so that 16ms * 2 are all displayed in the same frame, which is what I see as "stuck".

- tool

Hierarchy Viewer工具  \

- Solutions

  • am start -W com.nwd.can.setting/com.nwd.can.setting.ui.MainActivity
    insert image description here

- Start lag


- Jump stuck


- Response lag


2. Keep stable

insert image description here

problematic item reference URL
memory leak, memory overflow Reference knowledge points

- out of memory

Memory overflow: (out of memory) The common understanding is that the memory is not enough oom, usually when running large-scale software or games, the memory required by the software or games far exceeds the capacity of the memory installed in your host , which is called memory overflow.


- Memory Leak

  • Memory leak: (Memory Leak) refers to the heap memory that has been dynamically allocated in the program is not released or cannot be released for some reason, resulting in a waste of system memory, resulting in serious consequences such as slowing down the running speed of the program and even system crashes.

  • The consequences of memory leak accumulation are very serious, no matter how much memory, it will be taken up sooner or later.

  • Case 1


- crash

3. Save power and flow

insert image description here

4. Installation package size

insert image description here

Guess you like

Origin blog.csdn.net/oZiJing/article/details/118577184