Dalvik Virtual Machine (DVM)


Dalvik Virtual Machine (DVM)

As we know the modern JVM is a high performance and provides excellent memory management. But it needs to be optimized for low-powered handheld devices as well. 

The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile devices. It optimizes the virtual machine for memory, battery life, and performance. Dalvik is the name of a town in Iceland, The Dalvik VM was written by Dan Bornstein. The Dex compiler converts the class files into the dex file that runs on the Dalvik VM. Multiple class files are converted into one dex file.

Let's see the compiling and packaging process from the source file:

Dalvik Virtual Machine (DVM)

The javac tool compiles the java source file into the class file. The dx tool takes all the class files of your application and generates a single dex file. It is a platform-specific tool.

The Android Assets Packaging Tool (AAPT) handles the packaging process.

Role of Dalvik Virtual Machine (DVM)

The role of Dalvik Virtual Machine(DVM) is that In java we write and compile java programs using java compiler and run that bytecode on the java virtual machine. On the other side, In android, we still write and compile java source file(bytecode) on java compiler, but at that point, we recompile it once again using Dalvik compiler to Dalvik bytecode (dx tool converts java .class file into .dex format) and this Dalvik bytecode is then executed on the Dalvik virtual machine.