40

Since Android Lollipop, Google has replaced DVM with ART because ART is faster than DVM. Is there any other reason for that?

hata
  • 11,633
  • 6
  • 46
  • 69
Amit Prajapati
  • 13,525
  • 8
  • 62
  • 84

4 Answers4

98

There are some major performance improvements that ART brings which were lacking in Dalvik. But every pros have some cons too. I will try to discuss both the advantages and disadvantages here.


1) Compilation Approach

This is by far the biggest advantage of ART over Dalvik. The old guy Dalvik used Just-In-Time (JIT) approach in which the compilation was done on demand. All the dex files were converted into their respective native representations only when it was needed.

But ART uses the Ahead-Of-Time (AOT) approach, in which the dex files were compiled before they were demanded. This itself massively improves the performance and battery life of any Android device.

For example

In case of Dalvik, whenever you touch an app icon to open it, the necessary dex files gets converted into their equivalent native codes. The app will only start working when this compilation is done. So, the app is unresponsive until this finishes.

Moreover, this process is repeated every single time you open an app wasting CPU cycles and valuable battery juice.

But in case of ART, whenever you install an app, all the dex files gets converted once and for all. So the installation takes some time and the app takes more space than in Dalvik, but the performance is massively improved and battery life is smartly conserved.


2) Boot Time

In case of Dalvik, the cache is built with time the device runs and apps are used as is indicated by the JIT approach. So the boot time is very fast.

But in case of ART, the cache is built during the first boot, so the boot time is considerably more in case of ART. You might see an "Optimizing apps" dialog box sometimes you boot.


3) Space Usage

The space used by apps being run on ART is much more than that of Dalvik. Like a 20 MB app on Dalvik, takes more than 35 MB on ART.

So if you are on a low storage device, then this can be a huge disadvantage for you.


4) ART is Damn Fast

As discussed above, ART is extremely fast and smooth. Apps are very snappy and responsive. Any comparison between Dalvik and ART, will surely make the ART device win by a significant margin.

ART is the answer to all those who argued that iOS is faster and smoother than Android and is also more battery efficient.

Aritra Roy
  • 15,355
  • 10
  • 73
  • 107
  • " All the source files were converted into their respective byte code representations only when it was needed." This is wrong. JIT is to compile the Dalvik bytecode to native code. How can you expect source files exist in customers' systems? – Infinite May 10 '16 at 01:21
  • @Infinite Thanks for the corrections, have edited the answer accordingly. – Aritra Roy May 10 '16 at 07:07
  • 2
    some of this information is not correct any more. For example since Android N boot time is not slow any more. Compilation time is also fast because it switched to a JIT compiler for runtime profiling and optimizing – phuclv Dec 04 '16 at 12:11
  • nicely written. Helpful – Visakh Vijayan Sep 13 '20 at 18:31
7

In Android Lolipop, DVM has been replaced by ART. Because DVM converts bytecode everytime you launch a specific app. But ART converts it just once at the time of app installation. That makes CPU execution easier. ARM is a architecture. Like MIPS, x86 etc. DVM/ART runs on top of ARM. Both of them can not replace each other. I hope this clears your confusion.

kazisami
  • 168
  • 9
2

In Android 4.4 and above version, along with Dalvik, Google introduced a new Android Runtime called “ART”.

Difference between ART vs Dalvik

ART (Android RunTime) has main feature Ahead-of-Time (AOT) compilation,

AOT vs JIT

Android apps format is .apk and all Java classes converted into DEX bytecode. The DEX bytecode format is independent of device architecture and needs to be translated to native machine code to run on the device. This is the same for both the ART and the Dalvik runtimes.

Main Difference, ART (Android RunTime) used Ahead-of-Time (AOT) compilation,Dalvik is used Just-in-Time (JIT) compilation

With Dalvik ,Just-in-Time (JIT) compilation every Time when app run ,It convert dex byte code into machine code and cached.

see here more detail http://androidboost.over-blog.com/2016/10/art-vs-dalvik.html

Kamal Kakkar
  • 314
  • 1
  • 4
  • 13
-2

Since kitkat (Android version 4.4), Google has been replace the run time DVM to ART. Google do this because it will improve the performance while the application launched. in DVM while you click the app, it will compile the bytecode DEX and convert it to machine code, usually called JIT (Just In Time). Instead of running the compile process every time application launch, ART has changed that way by convert the bytecode DEX and convert it to machine code when application in installation step. This might be take a long time while you install the app, but it will be faster enough when you launch the app.

Cevin Ways
  • 984
  • 11
  • 13
  • No, DVM doesn't compile the app when you click on it. It interprets bytecode as it is and sometimes, may compile parts of the code (JIT) if it really necessary. – Vladimir Gordeev Dec 14 '20 at 09:54