Working of Dalvik Virtual Machine in Android

FREE Online Courses: Click for Success, Learn for Free - Start Now!

In this DataFlair Android article, we’ll read about Dalvik Virtual Machine(DVM). Android DDM was written by Dan Bornstein, and Dalvik is the name of a town in Iceland.

A Dalvik virtual machine enables Android applications to run in its own process with its own instance.

android dalvik virtual machine

Virtual Machine

Firstly let us understand what a virtual machine is? It is basically a software implementation of a physical computer. This implementation works like a real physical computer. It even compiles and runs programs the same as a physical computer. It can be understood like an emulator. There are some issues with virtual machines too. One is that it is less efficient when compared to physical computers. Another issue is its performance, which is unstable when multiple virtual machines are working simultaneously on the same machine.

Even though Java Virtual machine has a high performance and provides great memory management, it is not optimized for low-powered devices. Dalvik VM is also a virtual machine that is highly optimized for mobile devices. Thus, it provides all the three things, that are memory management, high performance as well as battery life. It is strictly developed for Android mobile phones.

Role of the Dalvik Virtual Machine

The Role of the DVM in Android includes:

  • Optimizing the Virtual Machine for memory, battery life, and performance
  • Conversion of class files into .dex file through Dex compiler that runs on Dalvik VM.
  • Converting multiple class files into dex files.

The Dex compiler helps convert the class file into .dex file, the following image shows how it flows:

  • First of all the .java file converts into .class file with the help of Java compiler.
  • Next .class file converts into .dex file using Dec compiler.
  • Then finally the packaging process is handled by the Android Assets packaging (aapt) tools.

Working of Android Dex Compiler

Dalvik Virtual Machine vs Android Runtime:

Let us see comparison between Android DVM and Android Runtime:

Dalvik Virtual MachineAndroid Runtime
Dalvik  is slower in comparison to Android RuntimeAndroid Runtime is faster than Dalvik Virtual Machine
Dalvik Virtual Mchine takes less time to boot, Booting is fastAndroid Runtime takes more time to boot, Booting is slow
The Cache builds up fast over time, reducing the reboot timeThe cache is built at first boot, increasing the reboot time
Dalvik Virtual Mchine needs less space as it uses Just In Time  compilerAndroid Runtime needs more space as it uses AOT.
Dalvik Virtual Mchine utilizes more battery, thus it has low battery performanceAndroid Runtime utilizes less battery, thus it has high battery performance
Dalvik Virtual Mchine has a poor Garbage collection when compared to Android RuntimeAndroid Runtime has a better Garbage collection when compared to DVM
In Android DVM, apps are less responsive in accordance with Android RuntimeApps here are very responsive and work smoothly.
Dalvik Runtime Virtual Machine converts bytecode every time the application launchesOn the other hand, Android Runtime converts the bytecode only once at the time of installation of application
It is a stable and time-tested virtual machineIt is highly experimented and new
DVM is the choice of Android developersIt doesn’t have a lot of support from app developers until now
DVM works better for lower internal storage devices as space occupied is lessIt consumes more internal storage space, as it stores compiled apps in addition to the APKs
It came prior to Android Runtime and it is replaced with Android RuntimeAndroid Runtime is the upgraded version of Dalvik Virtual Machine and comes up with a lot of improvements

Summary

Finally in this article, we have read about the Dalvik Virtual Machine. We started with what is Virtual machine, then saw what is the Dalvik VM in Android and what it does. Then we saw what the flow of conversion is. At the end, we compared Android DVM with Android Runtime.

Hope you enjoyed the article. Do rate us on Google to get more articles on latest technologies.

Did you like this article? If Yes, please give DataFlair 5 Stars on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *