1. Overview
Android4.4 to start using the art virtual machine, the Dalvik virtual machine we've been using before, then why did Google suddenly switch to Android-run virtual machines? There is only one answer: Art virtual machines are superior.
2.Dalvik vs ART
Dalvik
Android4.4 and previously used are Dalvik virtual machine, we know that the apk in the process of packaging will be Java and other source code through Javac compiled into a. class file, but our Dalvik virtual machine will only execute. dex files, this time DX will convert. class files to Dalvik The. dex file that the virtual machine executes. The Dalvik virtual machine will first convert the. dex file into a fast-running machine code when it starts, and because of the 65535 problem, we have a package process when the cold boot is applied, and the result is that our app starts slowly, which is the JIT feature of the Dalvik virtual machine (Just In time).
ART
Art virtual machines are Android virtual machines that are only started with Android5.0, and art virtual machines must be compatible with the features of Dalvik virtual machines, but art has a good feature AOT (ahead of time), This feature is that when we install the APK, Dex is processed directly into the machine code that can be used directly for the art virtual machine. Art virtual machines convert. dex files to directly run. Oat files, the art virtual machine natively supports multi-dex, so there is no one-pack process, so the art virtual opportunity is a big boost to the app's Cold boot speed.
3. Summary
Art Benefits:
Speed up app cold start
Boost GC Speed
Provides full-featured debug features
Art Disadvantages:
The app installs slowly because you want to build a running. oat file when the APK is installed
APK takes up a lot of space because you want to build a running. oat file when the APK is installed
Comparison of Android Dalvik virtual machines and art virtual machines