Thursday, 21 August 2014

Difference between JVM and DVM (JVM vs. DVM)

Hello Friends,

Let us have a look at difference between JVM and DVM (Dalvik Virtual Machine) 

1. DVM is the software that runs the applications on Android devices. It is open source.

2. JVM is Stack based whereas DVM is Register based.

Stack-based machines require more instructions(i.e. larger instruction set) than register-based machines for the same task. Whereas, each instruction in the register-based machines are larger.

3. Mobile Devices have limited memory and power , low CPU speed as compared to Desktops. 
So,  DVM is more efficient in terms of memory usage and performance.

 4. While running multiple instances of the DVM, DVM is supposed to be more efficient. In mobile phones, each application runs on its own sand box and thus each active application requires its own DVM instance.

Single instance of JVM is shared with multiple applications.

5.  Java compiler complies Java source code into .class files. Then dx (dexer) tool, which is a part of the Android SDK,  processes the .class files into .DEX files that contains Dalvik bytecode.

DVM runs .Dex file (Dalvik Executable File) whereas JVM runs .class files.

With dx tool, all the classes of the application are packed into one file. Also, all the classes in the same DEX file share field, method etc if they are same and these classes are loaded by the same class loader instance.

Thus dx tool eliminate all the redundant information that is present in the classes. 

6. JVM supports multiple operating systems. DVM only supports Android operating system.

7. In case if DVM, executable is APK whereas in JVM, executable is JAR.

8. In case of JVM, each class has its own constant pool. In the dex conversion,  all of the separate constant pools are collapsed into a single shared constant pool which is used by all classes in an application. Thus, storage space to store the shared constant pool is also conserved.

No comments:

Post a Comment