Dalvik Virtual Machine(DVM)
Dalvik Virtual Machine(DVM) is a register-based virtual machine that was created by Dan Borstein for Android.
Dalvik VM relies on Linux Kernel for various services such as memory management, process management and filesystem management.
DVM runs dex files.
Dex code is the byte code format onto which Java/Android code written to target to run on Dalvik Runtime get compiled to.
This compilation is done by the dx tool.
Dalvik VM runs on a Linux process with independent memory and file descriptors. It also takes care of its own group of threads.
These files are logically equivalent to Java byte code howeverm they target Dalvik Runtime as opposed to Java Virtual Machine(JVM).
Normally android code get packaged into a format called APK.Just like windows applications get package into exe.APK stands for Android Application Package. This packaging is done by a tool by known AAPT.
Then those APK files can be installed in devices, maybe downloaded from Google Play.
Why Dex and Dalvik?
You could think that Android designers could have based Android on JVM as opposed to DVM. However they didn't because of a couple of reasons:
|1.||Performance.||Mobile devices need extreme efficiency. When JVM was being designed it wasn't designed exclusively for mobile devices.The android designers wanted a Virtual Machine that could comfortably run on a low memory environment and they thought could do with something better than JVM.Dalvik VM can run Java code efficiently in a resource constrained environment. And mobile devices are such type of environment especially during the early days. For along time they've typically had limitations with respect to processing capability, the RAM and battery power.|
|2.||Licensing||There was also the other issue of licensing. Oracle has it's licensing requirements that they Android designers weren't so impressed by.They wanted a VM that could they could improve as per their wishes and also potentially open sourve community.|
The Dalvik Virtual machine employed JIT(Just In Time) compilation model beginning with Android 2.2.
JIT optimizes code and improves performance every time short portions of oftenly used bytecode are executed.
JIT provides the following advantages to DVM:
|1.||Significant Improvements in performance in terms of application execution.|
|2.||Decreased time spent on CPU intensive tasks.|
|3.||Better battery power efficiency.|
This leads to significant performance improvements and better battery power efficiency.