Android--------Java virtual machines and Dalvik virtual machines

Source: Internet
Author: User

Java Virtual machine

Virtual machine is an abstract computer, which is realized by simulating various computer functions on the actual computer. Java Virtual machine has its own perfect hardware architecture, such as processor, stack, register, etc., also has the corresponding instruction system. The Java Virtual machine masks information related to the operating system platform, allowing Java programs to run without modification on multiple platforms by generating only the target code (bytecode) that runs on the Java virtual machine.

The Java Virtual machine (Java VM abbreviation JVM) is an abstract computer that runs all Java programs and is the operating environment of the Java language, which is one of the most attractive features of Java.

Dalvik virtual Machines

Dalvik is Google's own virtual machine designed for use on Android platforms. Dalvik virtual Machine is one of the core components of Android mobile device platform developed by Google and other manufacturers. It can support the operation of a Java application that has been converted to. Dex (that is, Dalvik executable) format, which is a compression format designed for Dalvik and is suitable for systems with limited memory and processor speed. Dalvik is 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.

The DVM VM Dalvik virtual machine, which is the VM used in Android. All Android programs are running in the Android process. Each process corresponds to a Dalvik virtual machine instance.

Dalvik and Standard JavaVirtual machines the difference between (JVM)

Java virtual machines are stack-based.

The Java virtual machine is running Java bytecode.

The Java class is compiled into one or more bytecode. class files, packaged into a. jar file, and the Java virtual machine gets the appropriate bytecode from the corresponding. class file and the. jar file

The Dalvik virtual machine is a register-based

Dalvik virtual machine is running Dalvik byte code

After the Java class is compiled into a. class file, all the. class files are converted to a. dex file through a DX tool, and then the Dalvik virtual opportunity reads the instructions and data from it

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.

Dalvik Virtual Machine Architecture:

Android app compile and run process:

Java virtual machines are different from Dalvik virtual machine architectures. Java virtual machines are based on a stack schema. The virtual machine needs to read or write data frequently from the stack at run time. This process requires more command allocation and memory access times, which can take a lot of CPU time, which is a significant overhead for devices with limited resources for mobile devices. The Dalvik virtual machine is based on the register schema, and the access to the data is passed directly between registers, which is much faster than the stack-based approach.

Dalvik and the Java the difference between the operating environment1:dalvik mainly includes the completion of object lifecycle management, stack management, thread management, security and exception management, as well as garbage collection and other important functions. 2:dalvik is responsible for process isolation and thread management, and each Android application will have a standalone Dalvik virtual machine instance at the bottom, and its code can be executed under the virtual machine interpretation. 3: Unlike Java virtual machines running Java bytecode, the Dalvik virtual machine runs its proprietary file format, the Dex 4:dex file format, which reduces overall file size and improves the class lookup speed of I/O operations. The 5:odex is designed to further improve performance during operation and further optimize the Dex file. 6: All Android application threads correspond to a Linux thread, and virtual machines can therefore rely more on the operating system's thread scheduling and management mechanism 7: There is a special virtual machine process zygote, which is the incubator for virtual machine instances. It will be generated when the system starts, it will complete the initialization of the virtual machine, library loading, prefabricated class library and initialization operations. If the system needs a new instance of the virtual machine, it will quickly replicate itself and provide the system with the fastest data. For some read-only system libraries, all virtual machine instances share a memory area with zygote.

Android--------Java virtual machines and Dalvik virtual machines

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.