Dalvik Virtual Machine

Anshul vyas
2 min readSep 26, 2018

--

A virtual machine is like a software implementation of a physical computer which works like a real physical computer. It means a virtual machine can compile and run any program just like a physical computer does for us.

Dalvik is a purpose-built virtual machine designed specifically for android which was developed by Dan Bornstein and his team. Strictly it was developed for mobile devices. While developing Dalvik Virtual Machine Dan Bornstein and his team realize the constraints specific to the mobile environment which is not going to change in the future at least, like battery life, processing power and many more. So they optimized the Dalvik virtual machine.

JVM and Dalvik

Dalvik virtual machine uses register based architecture. With this architecture Dalvik virtual machine has few advantages over JAVA virtual machine such as:

  1. Dalvik uses its own 16-bit instruction set than java 8-bit stack instructions, which reduce the Dalvik instruction count and raised its interpreter speed.
  2. Dalvik uses less space, which means an uncompressed .dex file is smaller in size(few bytes) than compressed java archive file(.jar file).

In java code is written and compiles using java compiler and run that bytecode on the Java Virtual Machine. On the other side, In android code is still written and compiled java source file(bytecode) on java compiler, but at that point it is recompiled once again using Dalvik compiler to Dalvik bytecode(dx tool converts java .class file into .dex format and .odex format) and this Dalvik bytecode is then executed on the Dalvik virtual machine.

The successor of Dalvik is Android Runtime (ART), which uses the same bytecode and .dex files (but not .odex files), with the succession aiming at performance improvements transparent to the end users. The new runtime environment was included for the first time in Android 4.4 “KitKat” as a technology preview and replaced Dalvik entirely in later versions. Android 5.0 “Lollipop” is the first version in which ART is the only included runtime.

--

--

Anshul vyas

Product Engineer @ GO-JEK Tech | History and Literature Enthusiast |IIITIAN | Nerd | Music Lover |