class file differs from Dex file (DVM differs from JVM) and Android DVM Introduction

Source: Internet
Author: User

Difference One: The DVM executes a. dex format file The JVM executes a. class file After the Android program compiles the. class file, the Dex tool processes the. class file into a. dex file, and then packages the resource file and the. dex file into an. apk file. APK is the meaning of Android package. The JVM executes a. class file.

Difference Two: The DVM is a register-based virtual machine and the JVM executes the virtual machine based on the virtual stack. Register access speed is much faster than the stack, DVM can be based on hardware to achieve maximum optimization, more suitable for mobile devices.

The difference is that there is a lot of redundancy in the. class file, and the Dex tool removes redundant information and consolidates all the. class files into a. dex file. Reduced I/O operations and improved class lookup speed



the Android operating environment mainly refers to the virtual machine technology--dalvik. All Java programs in Android are running on Dalvik VMs. Every program on Android has its own thread, and DVM executes only. Dex's Dalvik executable file.    Each Android application should have an independent DVM instance on the ground floor and be executed under its interpretation.
Although DVM is also in the Java programming language, Dalvik virtual machines and generic Java virtual machines (Java VMS) are not compatible, the difference between the two is that the JVM standard executes the. class bytecode (bytecode), but the DVM executes its proprietary (. Dex) Execute the file. During compilation, Java compiles the class into one or more. Class byte code files, which are then packaged into jars where the JVM obtains the corresponding. class file and JRE bytecode from the jar file.    Although the Android VM is also programmed in the Java language, after compiling the Java program, it needs to be converted into. dex format by the Dex tool in the SDK, where the DVM reads the instructions and data.
Each application is a process (one of the Linux processes). The biggest difference is that the Java VM is a stack-based virtual machine (stack-based), and Dalvik is a register-based virtual machine (register-based).     Obviously, the latter's greatest benefit is that it can be optimized for hardware, which is better suited to the characteristics of mobile devices.
The DVM is ideal for use on mobile terminals, and it does not require a fast CPU and a lot of memory space compared to a PC. Google's calculations show that 64MB of memory has allowed the system to function properly. Where 24MB is used for initialization and startup of the underlying system. Another 20MB is used to start high-level services. A DVM has the following characteristics:
? Use the proprietary. Dex format.

The reason is that after compiling the Java class file, at least one. class file contains a large amount of Chen Yu information, and the Dex file format consolidates all the. class file contents into a. dex file. This reduces the overall file size and IO operations, but also improves the class lookup speed.

? added support for new opcode

The file structure is as concise as possible, using equal-length instructions to improve parsing speed.

Maximize the size of the read-only structure to improve data sharing across processes.

The structure of DEX files is compact, but if you want to improve performance at run time, you need to further optimize your Dex files for the following:

? Verify all classes in the Dex file

? Optimization of operation codes within specific classes and methods
? Adjust all the byte order (Little_endian) and align each domain in the structure
? Register-based virtual machines are less versatile than stack-based virtual machines, but their code execution efficiency is better
? Every Android app runs in its own DVM instance, and each DVM instance is a separate process space. All Android apps have threads that correspond to a Linux thread, and the DVM can therefore rely more on the operating system's thread scheduling and management mechanisms. Different applications run in different process spaces, and different applications are run with different Linux users to maximize the security and independence of the insured application http://blog.csdn.net/virus026/archive/2010/12/19/ 6085779.aspx

class file differs from Dex file (DVM differs from JVM) and Android DVM Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.