DEV Community

Cover image for Android Runtime and Dalvik
Tristan Elliott
Tristan Elliott

Posted on • Edited on

1

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)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay