Understanding Android: Zygote and Dalvikvm

Understanding Android: Zygote and DalvikVM

No. Dalvik doesn't span processes.

However, the Binder IPC mechanism can do a very convincing job of making objects appear to migrate to a different process and its Dalvik instance. Also, the memory management is very good about sharing read-only pages across all processes that need them. The Dalvik process hosting a typical app is forked off of zygote with all the common android libraries already mapped, so new unique copies don't have to be opened.

Source: Do apps using multiple processes share a Dalvik instance?

Also check these links:

http://davidehringer.com/software/android/The_Dalvik_Virtual_Machine.pdf

http://commonsware.com/blog/Articles/what-is-dalvik.html

What's the relationship between Dalvik and Zygote process?

Dalvik VM was authored by Dan Bornstein
Every android application runs in a separate process, has its own Dalvik VM.

Zygote is a daemon with the only mission to launch applications. This means that Zygote is the parent of all App process. When app_process launches Zygote, it creates the first Dalvik VM and calls Zygote’s main () method. Once Zygote starts, it preloads all necessary Java classes and resources, starts System Server and opens a socket /dev/socket/zygote to listen for requests for starting applications.

Understanding Android

Have you tried: https://sites.google.com/site/io/dalvik-vm-internals? There are a couple slides on Zygote.

Additionally, the link to the video is: http://youtu.be/ptjedOZEXPM, and the Zygote section is discussed at 13:43.

I hope this helps. (This would be better as a comment, but I don't have the reputation yet)

::Android Framework:: Which is first runner, zygote or dalvik?

Dalvik is shipped on Android as a loadable library. app_process links with that library, and uses it. As such app_process starts a Dalvik VM within its own process.

The Zygote is just a special case of this.

So, to more directly answer your question: During a typical start-up, the first Dalvik VM to run is one that is spawned within an app_process process, and it is passed arguments which cause it to become the Zygote process of the running system.

Understanding Android

Have you tried: https://sites.google.com/site/io/dalvik-vm-internals? There are a couple slides on Zygote.

Additionally, the link to the video is: http://youtu.be/ptjedOZEXPM, and the Zygote section is discussed at 13:43.

I hope this helps. (This would be better as a comment, but I don't have the reputation yet)

How does dalvikvm understand the starting point of android application

Android determines your app's entry point based on the AndroidManifest.xml shipped with your app. Specifically, Android determines which intent was sent to the app (to cause it to launch), and will instantiate the appropriate Activity and call its onCreate method. This creation process is overseen by a wrapper process called app_process, which calls into dalvik directly and sets up the app execution environment.

Dalvik itself behaves like a normal Java JVM in most regards; therefore, running a jar or dex with Dalvik will still expect a main method, as with normal Java.

Android dalvik virtual machine

  1. Use dx to convert your bytecode to dex
  2. use dalvikvm to run it

If you need help use -help option

$ dalvikvm -help

dalvikvm: [options] class [argument ...]
dalvikvm: [options] -jar file.jar [argument ...]

The following standard options are recognized:
-classpath classpath
-Dproperty=value
-verbose:tag ('gc', 'jni', or 'class')
-ea[:<package name>... |:<class name>]
-da[:<package name>... |:<class name>]
(-enableassertions, -disableassertions)
-esa
-dsa
(-enablesystemassertions, -disablesystemassertions)
-showversion
-help

The following extended options are recognized:
-Xrunjdwp:<options>
-Xbootclasspath:bootclasspath
-Xcheck:tag (e.g. 'jni')
-XmsN (min heap, must be multiple of 1K, >= 1MB)
-XmxN (max heap, must be multiple of 1K, >= 2MB)
-XssN (stack size, >= 1KB, <= 256KB)
-Xverify:{none,remote,all}
-Xrs
-Xint (extended to accept ':portable' and ':fast')

These are unique to Dalvik:
-Xzygote
-Xdexopt:{none,verified,all,full}
-Xnoquithandler
-Xjnigreflimit:N (must be multiple of 100, >= 200)
-Xjniopts:{warnonly,forcecopy}
-Xjnitrace:substring (eg NativeClass or nativeMethod)
-Xstacktracefile:<filename>
-Xgc:[no]precise
-Xgc:[no]preverify
-Xgc:[no]postverify
-Xgc:[no]concurrent
-Xgc:[no]verifycardtable
-XX:+DisableExplicitGC
-X[no]genregmap
-Xverifyopt:[no]checkmon
-Xcheckdexsum

You can also compile dalvikvm for x86 and run it in your host computer.



Related Topics



Leave a reply



Submit