Reputation: 13432
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?
Upvotes: 7
Views: 1057
Reputation: 40593
There are many reasons why running multiple applications in a single process doesn't work; here's two:
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.
If a process leaks memory and crashes, it harms only itself.
Upvotes: 5
Reputation: 157437
Why there is a separate instance of VM(Dalvik/ART) for every App?(the need for it)
It is a design decision, and in my opinion, is made to keep it simple. Every process runs in its own vm
. All the resources are allocated to that process, and the vm
, internally, has not to coordinate access to resources, e.g. FileDescriptor
s, I/O
etc. I never heard of multiprocess vm
(a vm that allows more than one process to run in it), but I found an article that you could give you an insight.
Upvotes: 1