What happens when an app is run?

When the Android Operating System boots, a process called Zygote is started and it listens for new app launch requests. Whenever a user clicks on an application, Zygote is used to launch it. Zygote creates a copy of itself using a fork system call when it receives a request to launch a new app. This process of launching a new app is considered more efficient and faster. The newly launched app process loads all the code that is required for it to run. What we read earlier is that the classes.dex file contains all the byte code compatible with Dalvik Virtual Machine. In the latest version of Android devices starting from Android 5.0, the default runtime environment is ART. In this new runtime environment, the classes.dex file will be converted into something called OAT using a tool called dex2oat.

ART – the new Android Runtime

ART has been first introduced in Android 4.4 as an optional runtime environment that could be chosen by the end user from developer options in the device. Google made it default from Android 5.0 (Lollipop). ART basically converts the application's byte code to native machine code when installed on a user's device. This is what is known as ahead-of-time compilation. Before the introduction of ART, Dalvik used to convert the byte code to native code at runtime on the fly when the app is run. This approach is known as JIT (Just-in-Time) approach. The benefit with ART is that the app's byte code doesn't need to be converted into machine code every time it starts as it is done during the app installation process. This may cause some delay on the first run but provides drastic performance improvement and battery life from the next run.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.48.161