Virtual machine working mode for Java Virtual machine

Source: Internet
Author: User

Today began the actual combat Java Virtual Machine two: "Virtual machine working mode."

Total of 5 Series

    • "Heap overflow processing" in one of the actual Java virtual machines
    • Virtual machine working mode for Java Virtual machine
    • The three "G1 of the New generation GC" of Java Virtual machine
    • Live Java Virtual machine Four "Disable System.GC ()"
    • Real-time Java Virtual Machine Five "turn on JIT compilation"

The current Java virtual machine supports both client and server two operating modes. Use the parameter-client to specify the use of the client mode, and use the parameter-server to specify the use of server mode. By default, the virtual opportunity automatically selects the operating mode based on the current computer system environment. Use the-version parameter to view the current pattern as follows:

    1. ./java-version
    2. Java version "1.7.0_40"
    3. Java (TM) SE Runtime Environment (build1. 7.0_40-B43)
    4. Java HotSpot (TM) Client VMs (build 24.0-b56, mixed mode, sharing)

With the-server parameter, you can get the following output:

    1. ./java-server-version
    2. Java version "1.7.0_40"
    3. Java (TM) SE Runtime Environment (build1. 7.0_40-B43)
    4. Java HotSpot (TM) Server VM (build 24.0-b56, mixed mode)


The server mode starts slower than the client mode because the server mode tries to collect more system performance information and optimizes the program with more sophisticated optimization algorithms. Therefore, when the system is fully up and running stable, the server mode executes much faster than the client mode. Therefore, for a long-running system in the background, using the-server parameter to start the overall performance of the system can have a small help. But for the user interface program, running time is not long, and the pursuit of startup speed, client mode is also a good choice.

From the trend of development, the future 64-bit system will inevitably gradually replace the 32-bit system, and in 64-bit systems The virtual machine is more inclined to run in server mode.

The various parameters of the virtual machine in server mode and client mode may vary greatly, and the reader can use the-xx:+printflagsfinal parameter if it needs to see the default values for a given parameter. This shows the difference between the client mode and the server mode, with the JIT compile threshold and the maximum heap as an example.

For the client mode, the parameters are as follows:

  1. ./java-xx:+printflagsfinal-client-version |grep-e ' compilethreshold| Maxheapsize '
  2. Intx compilethreshold = (+)
  3. Uintx maxheapsize: = 268435456 {product}
  4. Java version "1.7.0_40"
  5. Java (TM) SE Runtime Environment (build1. 7.0_40-B43)
  6. Java HotSpot (TM) Client VMs (build 24.0-b56, Mixedmode, sharing)

For the server mode, the parameters are as follows:

  1. ./java-xx:+printflagsfinal-server-version |grep-e ' compilethreshold| Maxheapsize '
  2. Intx Compilethreshold = 10000 {PD product}
  3. Uintx maxheapsize: =1073741824 {product}
  4. Java version "1.7.0_40"
  5. Java (TM) SE Runtime Environment (build1. 7.0_40-B43)
  6. Java HotSpot (TM) Server VM (Build 24.0-b56, Mixedmode)

As you can see, in client mode, the default value of Compilethreshold is 1500, that is, after the function has been called 1500 times, it will be JIT compiled (for more details on JIT compilation, see the 11th chapter "Troubleshooting and performance optimization of-JVM Java Virtual Machine"). In server mode, this value is 10000. Therefore, the system is more likely to interpret execution in server mode. Once compiled, the server mode is better than client mode. Second, for the maximum heap of the system, it is approximately 256M in client mode and approximately 1G in server mode. For other parameters, the reader can use a similar way to find comparisons.

    • "Heap overflow processing" in one of the actual Java virtual machines
    • Virtual machine working mode for Java Virtual machine
    • The three "G1 of the New generation GC" of Java Virtual machine
    • Live Java Virtual machine Four "Disable System.GC ()"
    • Real-time Java Virtual Machine Five "turn on JIT compilation"
Excerpt from

Virtual machine working mode for Java Virtual machine

Related Article

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.