CodeNewbie Community 🌱

Cover image for Android Runtime and Dalvik
Tristan
Tristan

Posted on

Android Runtime and Dalvik

Introduction

  • This series is going to be dedicated to the basic to Android development. Join me and let us try to build and understand some cool stuff. All the resources I used can be found HERE

Dalvik(DVM)

  • Before we talk about the Android Runtime(ART) it makes more sense to get a better understanding of it predecessor Dalvik.
  • So what is Dalvik? Well Wikipedia states, Dalvik is a discontinued process virtual machine in the Android operating system.. In less techy terms, Dalvik(DVM) is a virtual machine that is specialized to run on low memory mobile devices. In the early days of mobile phones, the main limiting factor was memory. Dalvik uses just in time compilation(JIT) which compiles small chunks of code at execution. Essentially, it compiles code it needs. This is a big help when it comes to memory limited environments.
  • So, Dalvik takes normal bytecode and then compiles it down to Dalvik bytecode which is stored in a .dex file. Those .dex files are then what gets run on our Android application. The .dex files are much more compact then normal class files, which again helps with memory consumption.

  • So basically Dalvik is a JVM that produces .dex files which are optimized for low memory environments.

Android Runtime(ART)

  • As the size of applications grew and phones became more powerful, Dalvik became more outdated and the user could see performance lagging. ART was created to fix the growing concerns. The major change with ART was the change from JIT compilation to ahead of time compilation(AOT). Instead of compiling code at runtime, code is compiled before running the app. This gave a large performance boost. ART still uses the .dex files, however, it gives us further optimizations to improve performance for the user. Some of the features introduced in ART are:

  • Improved garbage collection

  • Development and debugging improvements

  • A list of all the improvements can be found HERE

  • So essentially the Android Runtime(ART) is just a new and improved Dalvik

Conclusion

  • Thank you for taking the time out of you day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on Twitter.

Top comments (0)