Android Dalvik Virtual Machine and ART virtual machine comparison, androiddalvik
1. Overview
Android 4.4 and later started to use the ART virtual machine. Before that, we used the Dalvik Virtual Machine. Why did Google suddenly change to the virtual machine running Android? There is only one answer: the ART virtual machine is better.
2. Dalvik vs ART
Dalvik
Android4.4 and previously used Dalvik virtual machines. We know that the Apk will first compile the java and other source code through javac during packaging. class file, but our Dalvik virtual machine will only execute. dex file. At this time, dx will. the class file is converted to the Dalvik Virtual Machine for execution. dex file. When the Dalvik virtual machine is started. the dex file is converted to a fast-running machine code. Due to the 65535 issue, we had a package-breaking process during cold start of the application. The final result is that our app was slow to start, this is the JIT feature (Just In Time) of the Dalvik virtual machine ).
ART
The ART virtual machine is an Android virtual machine that is used only in Android5.0. The ART virtual machine must be compatible with the features of the Dalvik Virtual Machine. However, ART has a good AOT (ahead of time) feature ), this feature enables us to directly process dex into a machine code that can be directly used by the ART virtual machine when installing the APK. dex files can be converted to directly run. in oat files, the ART virtual machine supports multiple dex files, so there will be no package combination process. Therefore, the ART virtual machine greatly improves the cold start speed of the APP.
3. Summary
Advantages of ART:
Accelerate cold start of apps
Increase GC speed
Provides fully functional Debug Features
Disadvantages of ART:
Slow APP installation because the. oat file can be generated during APK Installation
The APK occupies a large amount of space, because the. oat file can be generated during APK installation.