Working of Dalvik Virtual Machine in Android
We offer you a brighter future with industry-ready online courses - 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.
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.
A Virtual Machine simulates the physical hardware of a computer, including CPU, memory and storage.Each VM acts as a separate entity of its own, isolated from other virtual machines if they are running on the same host.They can be configured to use specific amount of storage, RAM and memory from the host computer.
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 Dalvik Virtual Machine(DVM) was the original machine which was used by Android and it was replaced by Android RunTime(ART) when Android 5.0 was released. It executed bytecode generated from APK’s, which are compiled from Java source code into Dalvik Executable(DEX) files.
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.
Technology is evolving rapidly!
Stay updated with DataFlair on WhatsApp!!
Dalvik Virtual Machine vs Android Runtime:
Let us see comparison between Android DVM and Android Runtime:
Dalvik Virtual Machine | Android Runtime |
Dalvik is slower in comparison to Android Runtime | Android Runtime is faster than Dalvik Virtual Machine |
Dalvik Virtual Mchine takes less time to boot, Booting is fast | Android Runtime takes more time to boot, Booting is slow |
The Cache builds up fast over time, reducing the reboot time | The cache is built at first boot, increasing the reboot time |
Dalvik Virtual Mchine needs less space as it uses Just In Time compiler | Android Runtime needs more space as it uses AOT. |
Dalvik Virtual Mchine utilizes more battery, thus it has low battery performance | Android Runtime utilizes less battery, thus it has high battery performance |
Dalvik Virtual Mchine has a poor Garbage collection when compared to Android Runtime | Android Runtime has a better Garbage collection when compared to DVM |
In Android DVM, apps are less responsive in accordance with Android Runtime | Apps here are very responsive and work smoothly. |
Dalvik Runtime Virtual Machine converts bytecode every time the application launches | On 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 machine | It is highly experimented and new |
DVM is the choice of Android developers | It doesn’t have a lot of support from app developers until now |
DVM works better for lower internal storage devices as space occupied is less | It 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 Runtime | Android 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 know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google