Mobile App Performance Optimization: UI, Memory, Network, Power and Code
This article presents a detailed overview of mobile app performance optimization, covering UI responsiveness, memory management, network efficiency, power consumption, and code improvements, with practical analysis methods, tools, and case studies from major companies such as Ctrip and Alibaba to help developers enhance Android applications.
The article provides a comprehensive guide to performance optimization for Android applications, covering five major aspects: UI, memory, network, power, and code.
UI Optimization explains the importance of maintaining 60 fps (16 ms per frame) and introduces metrics such as Skipped Frames (SF) and Smoothness (SM). It describes common causes of UI jank—blocking calls on the main thread, complex layouts, overdraw, frequent layout passes, GC pauses, and redundant logic. Tools like GPU Overdraw, GPU Rendering Mode, HierarchyViewer, and TraceView are introduced for diagnosing and fixing UI issues.
Memory Optimization outlines Android’s memory management, OOM thresholds, and the role of the low‑memory killer. It presents strategies to avoid large object allocations, reuse objects, prevent leaks, and manage resources efficiently. Sample code illustrating a typical memory‑leak pattern is shown:
public final class MainActivity extends Activity {
private SignleInstance mInstance;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// SingleInstance is a singleton that holds a reference to MainActivity, causing a leak
mDbManager = DbManager.getInstance(this);
}
}Additional techniques include using onLowMemory() and onTrimMemory() callbacks, proper placement of drawable resources (e.g., using xxhdpi for 1080 p devices), and avoiding memory‑intensive patterns.
Network Optimization discusses server‑side and client‑side improvements: dynamic IP selection, TCP over HTTP, Protocol Buffers with Gzip compression, request merging, CDN caching, and adaptive strategies for weak networks. Real‑world results show a 76 % reduction in payload size and a 30 % decrease in latency.
Power Optimization recommends using network location instead of GPS when possible, reducing unnecessary network calls, limiting background services, leveraging JobScheduler, and distinguishing behavior between Wi‑Fi and 3G.
Code Optimization highlights replacing heavyweight Java collections with Android‑specific alternatives such as SparseArray and ArrayMap when appropriate, which reduces memory usage and improves lookup speed. The article cites a case where 225 HashMap instances were replaced with SparseArray in the Ctrip app.
Throughout the guide, case studies from Ctrip, Alibaba, and other large‑scale apps illustrate the impact of each optimization, and a final summary emphasizes balancing performance gains with architectural stability.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.