2

JVM and DVM both provide virtual environment. JVM doesn't need to be in every process. why DVM need to be in every process? Thanks.

0

2 Answers 2

7

Neither DVM nor JVM runs on every processes. Natively compiled applications (e.g. the ones you see inside Terminal Emulator) are not associated with any DVM or JVM.

And even when you only count Android "apk" applications, the overhead of having JVM/DVM on (nearly) every process' address space is minimal since they are a shared dynamic library so Linux will smartly load them once in a copy-on-write buffer for the whole OS.

4
  • Ah, I forgot about native C++ code, I suppose that wouldn't need to go through the JVM then.
    – Bryan Denny
    Commented Apr 1, 2011 at 12:55
  • I am a little confused. on android developer website: developer.android.com/guide/topics/fundamentals.html
    – user4009
    Commented Apr 1, 2011 at 22:56
  • I am still a little confused. on android developer website: developer.android.com/guide/topics/fundamentals.html line7: "Each process has its own virtual machine (VM), so an application's code runs in isolation from other applications. " but i think if we use JVM, JVM won't be in each process, but application's code still can be isolated from other applciations.
    – user4009
    Commented Apr 1, 2011 at 23:08
  • 1
    @librangel: Just as every Java apps need JVM, every Dalvik apps need DVM. That line is implicitly talking about Dalvik processes since most of Android applications are Dalvik applications. Native processes do not need DVM. Memory space isolation (virtual address space) is a feature of the Linux kernel, and each Dalvik application runs in their own process in their own virtual address space, however the kernel can smartly share memory used by shared libraries such as the DVM. So although physically they occupy the same area in RAM, each application conceptually has their own copy of DVM.
    – Lie Ryan
    Commented Aug 11, 2011 at 15:18
4

Android applications run Dalvik bytecode, so the DVM needs to be running. Just like how running Java bytecode on a PC requires a JVM to run.

2
  • I think java virtual machine doesn't need to run in EVERY process, right? Then why DVM needs to run in EVERY process?
    – user4009
    Commented Apr 1, 2011 at 1:13
  • 2
    @librangel It does need to run for every process. Something has to translate the byte code (what Java apps are "compiled" into) into machine language (that the processor executes)
    – Bryan Denny
    Commented Apr 1, 2011 at 1:40

You must log in to answer this question.