Noun explanation

The JVM is short for Java Virtual Machine, called Java Virtual Machine.

DVM is the abbreviation of Dalvik Virtual Machine, called Dalvik Virtual Machine.

The relationship between the two

DVM is for the JVM, which is the product of Oricle, concerned about copyright, and since Java is open source, it’s just a matter of studying the JVM and writing DVM.

DVM is a virtual machine for mobile devices.

The difference between the two

First, the architecture based on is different

Java is based on the stack architecture, which is a contiguous storage space above memory.

Android is register-based architecture, and a register is a piece of storage space on the CPU.

Therefore, it is more efficient for a CPU to access data directly on its own space than on its own memory.

Two, the execution of the bytecode file is different

JVM: Java — >. The class — – >. The jar

DVM: Java — >. The class — – >. Dex

Jar files contain multiple.class files. Each.class file contains header information (such as the compiled version), constant pool information, class information, fields, methods, properties, and so on. When the JVM loads the.jar file, it loads all of the.class files. Mobile devices have too little memory to load like a JVM, so instead of a.jar file, it uses an.apk file, which contains only a.dex file, which combines all the information contained in the.class so that it can be reloaded quickly. The. Class file contains a lot of redundant information, and the dex tool removes the redundant information and integrates all the. Class files into the. Dex file. Reduced I/O operations.

Three, the difference between the operating environment

DVM: Each application startup runs a separate DVM, and each DVM occupies a separate Linux process.

JVM: Only one instance can be run, that is, all applications run in the same JVM.

From: www.jianshu.com/p/78c0d173d…