Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Compare Dalvik virtual machine and the JVM     - Android engineers interview questions (Programming)

- Android Studio 1.0.2 set the memory size (Linux)

- How to choose the first programming language based on the life you want (Programming)

- MySQL binlog automatic cleanup script (Database)

- New experience Budgie (Budgerigar) desktop environment (Linux)

- Shell Script: Bulk add users, and set the random character password (Programming)

- Unable to solve the official version of Android Studio online update problem (Linux)

- Ubuntu modify DNS restart loss problem (Linux)

- Apache Kafka: the next generation of distributed messaging system (Server)

- True and false in Perl (Programming)

- Oracle 12C RAC on temporary table space Enlighten (Database)

- What is a logical partition management LVM, how to use in Ubuntu (Linux)

- Ubuntu 14.10 splash screen brightness settings (Linux)

- Linux shell script under the use of randomly generated passwords (Programming)

- TWiki LDAP error appears the problem is solved (Linux)

- 12 Linux Process Management Commands (Linux)

- Commentary Apache + Tomcat + JK implement Tomcat clustering and load (Server)

- Command line tool Tmux (Linux)

- SUSE Linux firewall configuration notes (Linux)

- Linux environment variable configuration (Linux)

  Compare Dalvik virtual machine and the JVM
  Add Date : 2018-11-21      
  Dalvik virtual machine and the Java Virtual Machine has many similar features, support GC, JIT, JNI, and so on. The main difference is the file format and instruction set of the following two characteristics compared with the discussions.

Difference1: File Formats

Dalvik virtual machine using dex class file format, and JVM class file format is class. The difference is, we are familiar with the class bytecode file contains only one class, but dex file can contain multiple classes. The advantage is that multiple classes of constant and repeated strings will keep a certain extent, saves space, but also adapted to run on the phone.

Difference2: Instruction Set

Dalvik is register-based instruction set, and the JVM stack-based instruction set. The difference is that, based on the instruction register in the register addressing, but faster instruction length is long; stack-based instruction set shorter, but more CPU time. Which is similar to CISC and RISC contrast contrast. From transplant, is clearly a stack-based instruction set more portable, it does not register for the target machine to do any optimization. And before hosting machine instruction set can then run the program on the target machine register the program optimization, this optimization is the process of optimizing compiler, JIT is not similar to the dynamic optimization during operation, but the ultimate goal is the program was converted to machine language.

Here, for the Dalvik virtual machine memory management, JIT, garbage collection, JIT, JNI, and process and thread management are discussed.

Memory Management

Dalvik virtual machine's memory can be divided into three parts: Java Object Heap, Bitmap Memory and Native Heap.

Java Object Heap used to store Java objects, the size of its different mobile phone manufacturers have different settings, you can get the maximum value by ActivityManager of getMemoryClass, the value is the maximum amount of memory that can be used in Android applications.

Bitmap Memory for storing and processing picture. Before Android3.0, Bitmap Memory is part of the Native Heap, the size of included Java Object Heap, namely bitmap objects and other java memory used can not exceed the maximum JOH above. After Android3.0, Bitmap Memory allocated directly in JOH, easy to GC.

Native Heap local machine language for the allocation of memory.


In Android2.3 previous releases, garbage collection policy Dalvik virtual machine as follows:

Garbage collection thread during execution, other threads are stopped so that a portion of the garbage collection completely, so the result is caused by a garbage collection program due to suspension time is usually greater than 100ms.

After Android2.3, garbage collection thread and other threads are executed concurrently, may only be a part of the garbage collection, so garbage collection program due to suspension time is greatly reduced, usually less than 5ms.


JIT is carried out in the course of running the compiled code is called repeatedly converted into native machine code saved, this process is performed dynamically at run time, with respect to the terms of the optimization program is compiled, JIT will take time to run the program . After Android2.2 began to support JNI.

Local calls

Java program to run on a virtual machine, the program needs to be translated into the target machine instructions to perform some functions need to call the target machine operating system interface to complete. Java local calls can help us in the Java code and C \ C ++ code, call the function with each other. Android NDK provides to help us achieve JNI.

Thread Management

Android process has two main features:

Android APP Each process has a Dalvik virtual machine instances, which guarantees multiple app at run time of each other.

Every Android application process is made of a Zygote process fork out. The Zygote process is created by the initialization process out. Zygote process at boot time, it creates a virtual machine instance, and in this instance all of the virtual machine Java core libraries are loaded up. Zygote process whenever you need to create an Android application process when it is achieved by copying itself, which is achieved by the fork system call. These are fork out Android application process, on the one hand is to copy the Zygote process virtual machine instances, on the other hand shared the same set of Java core libraries and Zygote process. Not only does the process of creating Android application process quickly, and because all of the Android application processes share the same core set of Java libraries and saves memory space.
- CentOS 6.5 x86_64 system customized automated deployment (Linux)
- Python 3 for instructions encoded string conversion (Programming)
- ORA-01000 Solution (Database)
- VirtualBox - Linux system virtual machine shared folders (Linux)
- Open log in Hibernate (Programming)
- Ubuntu system grub repair method (Linux)
- Debian users to install FFmpeg 2.2.2 (Linux)
- Expert advice: Do not use the computer security IE browser (Linux)
- CentOS 5.10 installed Oracle 11G R2 (Database)
- How to Install Cantata MPD 1.3.3 for Ubuntu and Derived Version Users (Linux)
- How to install Eclipse Luna IDE on CentOS 7 / RHEL 7 (Linux)
- How to Install Sticky Notes on Ubuntu and Derivatives (Linux)
- Let your PHP 7 faster the Hugepage (Linux)
- How to build Memcached Docker container (Server)
- PHP 5.3 New Features Detail (Linux)
- To access an Oracle database using Instant Client (Database)
- Bootstrap 3.3.5 release download, Web front-end UI framework (Linux)
- How to query the role of Linux services (Linux)
- How to fix Ubuntu / Mint can not add PPA source of error (Linux)
- RedHat6.4 installation tutorial --- Minimal Edition (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.