Java JVM and Android DVM differences

Source: Internet
Author: User

This article transferred from: http://blog.csdn.net/yujun411522/article/details/45932247 1. Android DVM process and Linux process, is the application process the same concept?
Dalvik virtual machines allow multiple instance to exist. Virtually every app in Android is running in its own VM instance (sandbox). Each VM instance is a separate process in Linux, so it can be considered the same concept. Running in their own DVM process, different apps don't interfere with each other and do not cause all app processes to crash because of a DVM crash. 1.1 What is a Dalvik virtual machine? Java requires a JVM (a lot of space later), as well as the Java language used in Android, and a VM. A VM that comes with a lack of hardware resources such as phone processors and memory provides an environment for Android to run. 2. Differences from the JVM
2.1. Schema-based differences. The JVM is based on StackArchitecture, and the DVM is based on Register DeviceArchitecture.
2.1.1 Why is the JVM designed to be a stack-based architecture, and DVM is based on the register architecture? Advantages: A. The instruction set based on the stack architecture is more easily generated (http://rednaxelafx.iteye.com/blog/492667);
B. Conserve resources. Its 0 address instructions are more compact than other instructions
C. Portability。 Considering that most of the applications used by the JVM are PCs and servers, the number of generic registers in the processor of this type of machine is different, if the use of register-based function is not much, and the stack architecture can freely allocate the actual registers, such PortabilityRelatively high, also in line with the Java design concept (once written, run everywhere).
Why a DVM is based on a register:
Advantage: The A.android handset manufacturer's processor is mostly based on the register architecture.
B. There are more instructions to dispatch and access memory in the stack architecture, which is time consuming. All relative to think of the implementation of the DVM Higher efficiencyA few.
C.DVM is designed to work with Android, regardless of the other platform's general purpose. 2.2.JVM runs a byte-code file, and DVM runs its own defined Dex file format
JVM Compilation Process Java->class->jar
The DVM compilation process is Java->class->dex. This process and the DX tool compiles all class files into a single Dex file and reconstructs multiple class files, with the benefit of reducing the overall file size because there are duplicate constants in different class files; All class files are generated in the same file, and the search speed is faster. Figure generating a Dex file from a Java file procedure the difference between a DVM and a JVM is simple.

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

3.Dalvik Design Rules3.1 Each app runs in its own DVM instance and is isolated from the app.
3.2 Start an app process, a DVM is born, the app code under the DVM instance to explain the run
3.3 There are several app processes that have several DVM instances.
3.4DVM manages the object life cycle (Component life cycle understanding), stacks, threads, exceptions, and garbage collection.
3.5 J2SE and J2ME APIs are not supported, and AWT and swing are not supported (with very little now) 4. Comparison with artIn Dalvik, every run of the app is converted to machine code by an instant compiler, which is a compilation process that slows down the operation. While art is in the installation, the bytecode is compiled directly into the machine code, to achieve a real local application, in the future run do not need to translate every time. This is faster, but consumes more storage space. (5.0 new Features) Details view http://baike.baidu.com/link?url= nkapr153-tub1qvdg21oseiauts0cs8ionqntgeh-rj7ldp-q7ufjonpvbmi6abol7wn3pf6_uu40f-sax_s1q Android DVM Profile
        Dalvik Virtual Machine is the foundation of the Android platform.

        one of the first differences between the Dalvik and the standard Java Virtual machine (JVM) is that the Dalvik is based on a register, and the JVM is stack-based. A register-based approach is chosen because it provides better support for pre-optimization (Ahead-of-time optimization), which is beneficial for a restricted environment like mobile phones. A further comparative analysis of register-based virtual machines and stack-based virtual machines indicates that register-based VMS are more time-consuming for larger programs when they are compiled.


        Another big difference between Dalvik and Java is that the operating environment--dalvik optimized to allow instances of multiple virtual machines to run concurrently in limited memory, and each Dalvik application executes as a standalone Linux process. A standalone process can prevent all programs from shutting down when the virtual machine crashes.


        Android Platform architecture diagram:



        :

        applications include: Home page, contact management, phone, browser, other;

        application frameworks include activity management, form management, content providers, view systems, package management, phone management, resource management, location management, notification management.

        libraries include: surface management, media framework, SQLite, OpenGL (3D Development Library), FreeType (font engine), WebKit (Web browser engine core library), SGL (2D Graphics engine Library), SSL, libc, Android Runtime ( Also includes core libraries and Dalvik virtual machines).

    The
        Linux kernel includes: Display driver, camera driver, memory driver, Binder (IPC) driver, keyboard driver, Wi-Fi driver, audio driver, power management.

        as a Java developer, the most likely connection is the Android runtime, which consists of two parts: the core library and the Dalvik virtual machine:

        1.Android includes a core set of cores libraries, which provides most of the functionality available in the core library of the Java programming language.


        2. Each Android application runs on its own process and has its own Dalvik virtual machine instance. Dalvik This is so that a device can run more than one virtual machine efficiently. The Dalvik VM executes the file in the Dalvik executable (. dex) format, which is optimized to occupy the smallest amount of memory. The VM is register-based and runs through the compilation of a Java language compiler, which has been converted to. dex format by the built-in "DX" tool (DVM relies on the Linux kernel).


        3.Dalvik MICROSOFTVM relies on the Linux kernel for basic functionality, such as threading and underlying memory management.


      Android also contains the key performance of the common mobile platform, which already has a good stack, including Bluetooth, EDGE, 3G and WiFi. In terms of UI, OpenGL ES is supported to provide interface management (surface management) that is similar to iphone.

Java JVM and Android DVM differences

Related Article

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.