2.JVM operating mechanism-JVM sequence

Source: Internet
Author: User

Last written 1. A preliminary understanding of the JVM-the JVM sequence, followed today to write the JVM's operating mechanism.

First, the JVM startup process

The Java platform includes the JVM and the Java language, where the JVM is also an application process running in the operating system, and it should have its own lifecycle and memory space. In general, the Java or JAVAC command execution process is probably as follows:

    • Input java (javac) command

    • Loading environment and configuration (looking for jvm.cfg based on current path and system version)

    • Locate and load JVM.DLL based on configuration

    • Initialize JVM to get JNIEnv interface

    • Find the Main method

Note in the loading environment and in the configuration first find the JRE path and then load Jvm.cfg, and then locate the calling system API to load JVM.dll, as for the specific code execution process can see csdn this article more complete.

Two JVM Basic Structure

This basic structure I crawled from the Web to view this more clearly, as follows:

    • This method area typically holds the loaded class information: a constant pool of types, field, method information, method bytecode (string constants move the heap after JDK1.7). The

    • Java heap should be said to be the most closely related to the development of the program, which holds the system objects are stored in the heap, not like the stack is thread-private, this heap is all thread sharing, in particular, it is necessary to note that the GC has generational so the heap is also generational.

    • Java stack is said to be thread-private, the stack of space for the heap is generally relatively small so it is not possible to store large objects or quantities, each call method will create a frame and press the stack then allocate the stack space, but also have a PC register to save the next instruction address ( Local methods are different), there are multiple frames to follow the principle of advanced after, this frame holds the method of local variables, the operand stack (there is no register concept in Java), constant pool and other information, about the local variables here you need to remember the local variable table static method and instance method of the difference, for example:

  1. public staticint runstatic (int  i,long lfloat f,object  o,byte b) {}
  2. Local Variables table:int i,long l,float f,Object o,byte b
  3. public int runinstance(char- c, short s,boolean b) {}
  4. Local Variables table:reference this,char c,short s,boolean b
  5. Note: a minimum of 4 bytes ,int: N;float: n-bit;Object: the first place.
    • Heap, stack, method area interaction: About this interaction diagram I went straight to the video so look clearer, as follows

      Come here first this time. Keep a record of every bit of drip!

2.JVM operating mechanism-JVM sequence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.