Android Runtime Environment explained Edited by Pulak at 2016-02-18 22:48
Before getting into the topic, first let us understand the basic. What Is A Runtime Environment? To put in simplest terms, runtime comprises of software instructions that execute when your program is running. These instructions basically translate the software's own code into the code that the computer is capable of running. Therefore, all computer languages require some sort of runtime environment that can properly execute the code written in the programming language. Android makes use of a virtual machine as its runtime environment in order to run the APK files that constitute an Android application. The advantage of using a virtual machine is twofold – firstly, the app code is isolated from the core operating system, ensuring that should something go wrong, it’s contained in an isolated environment and does not effect the primary OS. And secondly, it allows for cross-compatibility, meaning even if an app is compiled on another platform (such as a PC, as is usually the case with developing mobile apps) , they can still be executed on the mobile platform using the virtual machine. Runtime Environment in Android An android device uses any one of the following runtimes -
ART (Android RunTime) has been introduced from Android KitKat as an option. Prior to that dalvik was the only runtime. From Android L ART has been promoted as the primary and dalvik as an extra option. We can consider ART/dalvik as mobile optimized version of JVM (Java Runtime Machine). Why ART is preferred over dalvik? Android apps comes in .apk format. Application code are essentially written in Java (.javaclasses) which are bundled in apk files. While application gets bundled, java classes are compiled and converted to bytecodes (.dex) files. This is common for both Dalvik as well as ART. Difference is what comes next. Dalvik uses JIT (Just In Time) technology, where every time an application is launched byte code is interpreted line by line. If a routine or function is identified as hotspot it is directly compiled to native code (machine code) by JIT with optimization. This leads to time and memory footprint overhead as this is done on the fly when application is running. The JIT compiled code is then run directly everytime thereafter (no interpretation needed) which increases the performance. ART uses AOT (Ahead Of Time) trchnology, where when an application (.apk) file is installed entire byte code is converted to machine code and stored in the persistent storage. As this is on installation this happens only once. Every time the application is launched this machine code is directly executed. No need of interpreter. Yes it takes more storage space as compiled native code is stored in the storage but takes less CPU and less RAM (memory footprint). Following are the basic differences between ART and Dalvik
| |||||||||
SignatureFAN |
|||||||||
Note: The author has been banned or deleted.
| |
|
|
Very well explained...
| |
|
|
More knowledge
| |
|
|
Nice explain mainly art and dalvik difference aswamm...able to know basic from this difference....Thanks for share...
| |
|
|
ark45 replied at 2016-03-21 11:32 | |
|
|
Good stuff.. Explained very well and in detail
| |
|
|
6