Learning Journey - Android Two Virtual Machines

Every time I see related knowledge about virtual machines, I read some blogs of great gods, and decided to organize a note that I read by myself. It’s really a long text, and my eyes are tired when I look at it on the computer.

JVM : JVM is essentially a piece of software, a layer of software abstraction for computer hardware, on which Java programs can be run

          Jvm is right. Java text is compiled into .class bytecode files. When executing a java program, the class loader loads all the required classes into the memory.

DVM : DVM is Dalvik Virtual Machine, which is a virtual machine used in Android. All Android programs run in the Android system process, and each process corresponds to a Dalvik virtual machine instance

        The .dex file is to put constants, methods, etc. in multiple class files together

The picture below shows the difference between the two

①The JAVA virtual machine runs JAVA bytecode, and the Dalvik virtual machine runs Dalvik bytecode

②The size of the Dalvik executable file is smaller (reason: In order to reduce the size of the executable file, Android uses the Dalvik virtual machine, and there is a dx tool in the SDK that is responsible for converting JAVA bytecodes to Dalvik bytecodes, and the dx tool recreates the Java class files. Arrange, decompose the constant pool in all JAVA class files, eliminate redundant information, and recombine to form a constant pool. All class files share the same constant pool, so that the same strings and constants only appear in the DEX file. once, thus reducing the size of the file )

③JVM is based on the stack ( so every time the CPU accesses the data, the data must be fetched from the memory ), DVM is based on the register ( the register is a storage space on the CPU, if the CPU directly reads data from the register, it will be much faster )

Reference document https://blog.csdn.net/kent_todo/article/details/22331379

https://www.jianshu.com/p/8edac8e09b3e

Guess you like

Origin blog.csdn.net/qq_22576071/article/details/81195845