Practice: Java Virtual Machine 2 "virtual machine working mode", Java Virtual Machine

Source: Internet
Author: User

Practice: Java Virtual Machine 2 "virtual machine working mode", Java Virtual Machine

Today, I started to practice Java Virtual Machine II: "virtual machine working mode ".

5 Series in total

  • One of the actual Java virtual machines is "Heap Overflow processing"
  • Practice: Java Virtual Machine 2 "virtual machine working mode"
  • Java Virtual Machine 3: New Generation GC of G1"
  • 4. Disable System. gc () for Java virtual machines ()"
  • 5. "enable JIT compilation"

Currently, Java virtual machines support both Client and Server running modes. You can use the parameter-client to specify the Client mode and the parameter-server to specify the Server mode. By default, the virtual opportunity automatically selects the running mode based on the current computer system environment. Use the-version parameter to view the current mode, as shown below:

  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 VM (build 24.0-b56, mixed mode, sharing)

 

After the-server parameter is used, the following output is displayed:

  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)


Compared with the Client mode, Server mode is slower to start, because Server mode will try to collect more system performance information and use more complex optimization algorithms to optimize the program. Therefore, when the system is fully started and enters a stable period of operation, the Server mode will run much faster than the Client mode. Therefore, using the-server parameter to start a system that runs on the background for a long time can be of great help to the overall performance of the system. However, for user interface programs, the running time is not long and the startup speed is pursued. The Client mode is also a good choice.

 

From the perspective of development trends, the 64-bit system will inevitably replace the 32-bit system in the future, while the 64-bit system tends to run in Server mode.

The parameters of virtual machines in Server mode and Client mode may be very different. If you need to view the default values of a given parameter, you can use the-XX: + PrintFlagsFinal parameter. The JIT compilation threshold and the maximum heap are used as examples to show the differences between the Client mode and the Server mode.

For Client mode, the parameters are as follows:

  1. ./Java-XX: + PrintFlagsFinal-client-version | grep-E 'compilethreshold | maxheapsize'
  2. Intx CompileThreshold = 1500 {pd product}
  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 VM (build 24.0-b56, mixedmode, sharing)

For 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)

 

In Client mode, the default value of CompileThreshold is 1500, that is, after the function is called for 1500 times, JIT compilation is performed. (For more information about JIT compilation, see Chapter 11th "Practical Java Virtual Machine-jvm Fault Diagnosis and performance optimization ). In Server mode, the value is 10000. Therefore, the system is more likely to interpret and execute in Server mode. Once compiled, the Server mode is better optimized than the Client mode. Secondly, for the maximum system heap, the value is about 256 M in Client mode, and about 1G in Server mode. For other parameters, you can search and compare them in a similar way.

 

  • One of the actual Java virtual machines is "Heap Overflow processing"
  • Practice: Java Virtual Machine 2 "virtual machine working mode"
  • Java Virtual Machine 3: New Generation GC of G1"
  • 4. Disable System. gc () for Java virtual machines ()"
  • 5. "enable JIT compilation"
Excerpted from

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.