Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there a separate instance of VM(Dalvik/ART) for every App on Android?

As the title states,
Why is there a separate instance of VM(Dalvik/ART) for every App on Android?(the need for it)

and, what would have happened if the Android OS had chosen a model where a single VM runs all the apps?

like image 735
Manish Kumar Sharma Avatar asked Jun 28 '15 11:06

Manish Kumar Sharma


People also ask

Is a Dalvik virtual machine instance created for each application?

Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable ( . dex ) format which is optimised for minimal memory footprint.

Why does Android run each app inside a separate process?

In most cases, every Android application runs in its own Linux process. This process is created for the application when some of its code needs to be run, and will remain running until it is no longer needed and the system needs to reclaim its memory for use by other applications.

Why does Android use its own virtual machine?

Why android needs a virtual machine is on the basis that Google engineered Android API to vastly use a Java interface. Java itself is usually run on a virtual machine. The purpose of a virtual machine is to be able to abstract hardware by simulating it.

What is Dalvik and ART in Android?

ART and its predecessor Dalvik were originally created specifically for the Android project. ART as the runtime executes the Dalvik Executable format and Dex bytecode specification. ART and Dalvik are compatible runtimes running Dex bytecode, so apps developed for Dalvik should work when running with ART.


1 Answers

There are many reasons why running multiple applications in a single process doesn't work; here's two:

Security zones.

Two applications that don't trust one another shouldn't be able to view each other's memory, even if they use native code or reflection.

Failure isolation.

If a process leaks memory and crashes, it harms only itself.

like image 122
Jesse Wilson Avatar answered Apr 27 '23 07:04

Jesse Wilson