What is Dalvik and dalvik-cache?
I know this may be a basic quest开发者_StackOverflow社区ion in Android. But what is Dalvik and dalvik-cache?
Dalvik is the virtual machine that is used by Android. It is generally thought of as a Java virtual machine, although this is not precisely correct. It uses an object model that is identical to Java, and its memory model is also nearly equivalent. But the dalvik VM is a register based VM, as opposed to Java VMs, which are stack based.
Accordingly, it uses a completely different bytecode than Java. However, the Android SDK includes the dx tool to translate Java bytecode to dalvik bytecode, which is why you are able to write Android applications in Java.
When you say "dalvik-cache", I assume you mean the /data/dalvik-cache directory that can be found on typical Android devices. When you install an application on Android, it 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.
Dalvik is the java based Virtual Machine that runs Android Apps on Android. Dalvik-cache is the cache area for Dalvik VM, it is created when the Dalvik VM optimizes your app for running.
You can look up more on the internet about the differences between Dalvik VM op-codes and a "normal" Java VM Op-codes if you want.
Dalvik Caches are nothing but the temporary compilation of application code being stored as executables. As these can be compiled dynamically from the original application code sitting outside the Dalvik Cache, you can clear the Dalvik Cache without any real penalty.
The Dalvik cache is no part of modern Android versions anymore; Android 4.4 KitKat was the last to make use of this construction. See https://en.wikipedia.org/wiki/Dalvik_(software) for more details.
精彩评论