JVM Server and Client operating modes

The main difference between JVM server mode and client mode startup is: - When the server mode starts, the speed is slower, but once it starts up, the performance will be greatly improved. The reasons are:

When the virtual machine runs in -client mode, a lightweight compiler code-named C1 is used, while the virtual machine started in -server mode uses a relatively heavyweight compiler, code-named C2. C2 is better than the C1 compiler The compilation is relatively thorough, and after serving, the performance is higher.

Java  -version can directly check whether you are using client or server

JVM client code:

[java]  view plain  copy
  View code snippets on CODE Derive to my code slice
  1. C:\Documents and Settings\Administrator>java -version  
  2. java version "1.6.0_21"  
  3. Java(TM) SE Runtime Environment (build 1.6.0_21-b06)  
  4. Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)  

JVM server code:

[java]  view plain  copy
  View code snippets on CODE Derive to my code slice
  1. [root@kaifa02 ~]# java -version  
  2. java version "1.6.0_06"  
  3. Java(TM) SE Runtime Environment (build 1.6.0_06-b02)  
  4. Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)  

Switching between the two modes can be achieved by changing the configuration (jvm.cfg configuration file):

The 32-bit virtual machine is in the directory JAVA_HOME/jre/lib/i386/jvm.cfg,

64-bit is in JAVA_HOME/jre/lib/amd64/jvm.cfg, currently 64-bit only supports server mode, the configuration content is roughly as follows

[java]  view plain  copy
  View code snippets on CODE Derive to my code slice
  1. -server KNOWN  
  2. -client KNOWN  
  3. -hotspot ALIASED_TO -client  
  4. -classic WARN  
  5. -native ERROR  
  6. -green ERROR  

Generally, you only need to change the order of the two configuration locations of -server KNOWN and -client KNOWN, provided that there are two folders, server and client, in the JAVA_HOME/jre/bin directory, which correspond to their respective jvms.

If one of them is missing, an error will be reported when switching modes. Similar to the following figure:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325960647&siteId=291194637