Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When installing custom ROMs most recommend clearing the Dalvik cache. What exactly is Dalvik cache?

share|improve this question
up vote 25 down vote accepted

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.

share|improve this answer
    
Is it thus normal for a freshly installed ROM with wiped Dalvik cache to take a long while to boot the first time? because ParanoidAndroid is sure taking its sweet time; five minutes and counting. – badp Apr 27 '13 at 6:35
1  
@badp Yep, my first boots were often that long with various ROMs. I wouldn't give it too too long before assuming something's wrong though. – Matthew Read Apr 28 '13 at 1:25

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.