“Dalvik”, it’s a word that gets thrown around when you’re talking about custom ROMs, particularly when flashing a new ROM and the need to “Wipe the Cache”. Today you’ll find out what that means (just in case you didn’t already know).
In our last episode we talked about JIT, or “Just In Time”, which is the compiler built into newer versions of Android. We sort of put the cart before the horse with that one, but it helped open the discussion about one of the most powerful aspects of Android: Dalvik.
What’s a VM?
Computers run on physical hardware (like desktops or laptops). These “machines” have components inside them and drivers that allow software to talk to the hardware. But hardware doesn’t have to be physical, it can be virtual. In this case, a “virtual machine” or “VM” looks like it’s a real computer, but it’s not. This allows users a lot of flexibility and even added security.
In Android, apps are run in the Dalvik Virtual Machine.
Dalvik? What kind of name is that?!
Dalvik is open-source software that was originally written by Dan Bornstein. He reportedly had ancestors who lived in a fishing village called Dalvík in Eyjafjörður, Iceland.
Android apps are written in Java, compiled to bytecode, then converted from Java Virtual Machine (JVM)-compatible .class files to Dalvik-compatible .dex (Dalvik Executable) files before they’re installed on your Android. The Dalvik Executable format is compact and designed to for systems that have limited memory and processor speeds.
What about the Cache?
When your smartphone or tablet starts, the Dalvik VM inspects all your apps and creates a tree of dependencies which is stored in something called the Dalvik Cache. This enables your apps to run more optimized and is why your phone takes longer to boot up after you just flashed a new ROM or update — it’s rebuilding the cache.