Dalvik : Simple Introduction

Dalvik is the virtual machine that is used by Android. It is generally thought of as a java virtual machine, although this is not precisely correct. It uses an object model that is identical to java, and it’s memory model is also nearly equivalent. But the dalvik VM is a register based VM, as opposed to java VMs, which are stack based.

Accordingly, it uses a completely different bytecode than java. However, the Android SDK includes the dx tool to translate java bytecode to dalvik bytecode, which is why you are able to write Android applications in java.

When you install an application on Android, it performs some modifications and optimizations on that application’s dex file (the file that contains all the dalvik bytecode for the application). It then caches the resulting odex (optimized dex) file in the /data/dalvik-cache directory, so that it doesn’t have to perform the optimization process every time it loads an application.

JVM vs Dalvik