What is the difference between DVM and JVM?

64,071

Solution 1

DVM is Register based which is designed to run on low memory, uses its own byte code and runs .Dex file

JVM is Stack based which uses java byte code and runs .class file having JIT.

Java source code is compiled by the Java compiler into .class files. Then the dx (dexer) tool, part of the Android SDK processes the .class files into a file format called DEX that contains Dalvik bytecode. The dx tool eliminate all the redundant information that is present in the classes. In DEX all the classes of the application are packed into one file. DVM has been designed so that a device can run multiple instances of the VM efficiently.

stack-based machines must use instructions to load data on the stack and manipulate that data, and, thus, require more instructions than register machines to implement the same high level code, but the instructions in a register machine must encode the source and destination registers and, therefore, tend to be larger.

Solution 2

Conceptually, there is little difference from an application level between a DVM and a JVM. Architecturally, there is a major difference between the registerbased DVM and the stack-based JVM.

Both use a VM code model. However, the DVM uses registerbased opcodes that are comparable to the register-based bytecode instructions that most of the target platforms already execute. This includes architectures such as those available from ARM and MIPS and the x86-compatible architectures from Intel, AMD, and VIA Technologies.

Google developed Android and chose DVM for several reasons. First, there were licensing issues with most JVMs. Next, the DVM should be more efficient in terms of memory usage and performance on a register-based machine. DVM is also supposed to be more efficient when running multiple instances of the DVM. Applications are given their own instance. Hence, multiple active applications require multiple DVM instances. Like most Java implementations, the DVM has an automatic garbage collector.

More about it

Solution 3

The jvm architecture is stack-based whereas the dvm architecture is register-based. Stack-based machines require more instructions(i.e. larger instruction set) than register-based machines for the same task. On the other side, each instruction in the register-based machines are larger.

Solution 4

When a Java virtual machine start running a program, it needs memory to store many things, including bytecodes and other information it extracts from loaded class files, objects the program instantiates, parameters to methods, return values, local variables, and intermediate results of computations.

The Java virtual machine organizes the memory it requires to execute a program into several runtime data areas.

Generally, stack-based machines must use instructions to load data on the stack and manipulate that data, and, thus, require more instructions than register machines to implement the same high level code, but the instructions in a register machine must encode the source and destination registers and, therefore, tend to be larger.

This difference is primarily of importance to VM interpreters for whom opcode dispatch tends to be expensive and other factors are relevant for JIT Compilation.

Being optimized for low memory requirements, Dalvik has some specific characteristics that differentiate it from other standard VMs>>>>>

The VM was just slimmed down to use less space--->> Dalvik currently has no just-in-time-compiler (JIT), but Android 2.0 includes experimental source for one (disabled by default). The constant pool has been modified to use only32-bit indexes to simplify the interpreter. It uses its own bytecode, not Java bytecode***

Solution 5

Dalvik VM can't execute Java bytecode(.class) It has to be(.dex)

Oracle JVM has stack based architecture & Dalvik has register based architecture.

JVM suppost to multiple operating system. (it is open source) but DVM supported for Android Operating system (before comming android 5.o android used the DVM)

Share:
64,071

Related videos on Youtube

anish
Author by

anish

developer in android .

Updated on July 05, 2022

Comments

  • anish
    anish almost 2 years

    What is difference between Java Virtual Machine and Dalvik Virtual Machine?

    • Apurva
      Apurva almost 9 years
      Why none of any answer is accepted?
    • Manoj Perumarath
      Manoj Perumarath over 5 years
      is our smartphone a dvm? or the emulator?
  • roottraveller
    roottraveller about 8 years
    Don't we have limited no of available register?
  • Jemshit Iskenderov
    Jemshit Iskenderov over 7 years
    From Android 2.2 JIT is used, from Android 5.0 (which replaced DVM with ART) AOT is used, then from Android 7.0 both AOT and JIT are used.
  • LightSith
    LightSith about 4 years
    JVM instance is not shared stackoverflow.com/questions/5947207/…