Android - What is Dalvik cache?

The Dalvik cache is the set of saved .dex files. A .dex file is basically a compiled bytecode version of an app that has been built for the Dalvik Virtual Machine on which Android's apps run. It's similar to the Java Virtual Machine and having saved .class files.


Found very insightful information on dalvik-cache at stackoverflow from reputed sources(Google's employees who worked on Dalvik virtual machine platform).

Below is the summary of it, more from Android User's perspective in (hopefully) simple words.

Where is dalvik-cache located in my Android device ?

In a typical Android device, there is a directory named dalvik-cache. Since Android is based on Linux, it uses a file-system structure of the linux kernel. Hence, this directory is located in /data folder. So the path to access this Dalvik cache in Android device is /data/dalvik-cache

What is purpose of Dalvik cache?

When a user installs new application on Android, Android performs some modifications and optimizations on that application's dex file (the file that contains all the dalvik bytecode for the application). It then caches the resulting odex (optimized dex) file in the /data/dalvik-cache directory, so that it doesn't have to perform the optimization process every time it loads an application.

What if I clear Dalvik Cache?

There is no effect, other than increasing the next load time of an app, as it is rebuilt. So an application will take more time to load as it needs to rebuild it's Dalvik Cache. Hence, its is OK to clear dalvik-cache when installing custom ROMs, as the system will anyway re-build it with a new partition.

On an additional note, Starting from Android 4.4(KitKat), Google introduced new Android Runtime called ART which is going to ultimately replace the Dalvik Virtual machine. Source

The ART which uses the same bytecode and .dex files compiles the dex file into native code. That compiled code is what is now stored in dalvik-cache