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:
JVM server code:
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
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: