Android & Jetpack Compose (50 Qs)•Part 3: ART Internals, Memory Leak Profiling & Production Hardening (25 - 35)
Android ART vs Dalvik: AOT, JIT with Profile-Guided Optimization (PGO), and Cloud Profiles.
senior LevelPerformanceMemory Management
In Simple Words: How Android executes compiled DEX bytecode:
- Dalvik (Legacy): Interpreted bytecode with basic Just-In-Time (JIT) compilation; high CPU overhead and slow app launch.
- ART AOT (Android 5.0): Compiled all bytecode into native machine code at install time. Caused massive 20-minute app install delays and huge storage bloat.
- ART Modern Hybrid (PGO + Cloud Profiles):
- Apps install quickly with JIT.
- While the user interacts with the app, ART records a profile of hot methods and classes.
- When the phone is idle and charging, ART compiles only the hot profile methods into native machine code.
- Cloud Profiles: Google Play aggregates profiles across thousands of users and ships pre-compiled profiles inside the APK, delivering instant AOT speed on day one!