Why is -server option there when server VM is the default option?

前端 未结 3 1064
一整个雨季
一整个雨季 2020-12-10 17:46

The help menu for java command says that -server option is to select the \"server\" VM. It also states that \'server\' is the default option. Why s

相关标签:
3条回答
  • 2020-12-10 18:15

    The -server mode might be default in most JVM versions but there are exceptions. As per Where do I get the server and client systems? docs:

    Client and server systems are both downloaded with the 32-bit Solaris and Linux downloads. For 32-bit Windows, if you download the JRE, you get only the client, you'll need to download the SDK to get both systems.

    For 64-bit, only the server system is included. On Solaris, the 64-bit JRE is an overlay on top of the 32-bit distribution. However, on Linux and Windows, it's a completely separate distribution.

    At the end of the day you can use -client to switch back to client mode and sacrifice JIT optimization for faster startup time.

    0 讨论(0)
  • 2020-12-10 18:27

    -client and -server are ignored on modern JVMs, as easy as that. There are two JITcompilers C1 and C2, but there are 5 tiers, all the details in the entire glory are here in the comments.

    These flags used to control how C1 and C2 would act - disable or not; this is now controlled by two other flags : XX:-TieredCompilation -XX:TieredStopAtLevel=1

    0 讨论(0)
  • 2020-12-10 18:31

    I don't know your java version, IMHO, in java8 or older versions, for different platforms(different architecture and OS, or even different cup cores and memory), there are different default JVM(server or client).

    This picture is taken from https://docs.oracle.com/javase/8/docs/technotes/guides/vm/server-class.html, we can see the situation for java6.

    (Note: For Java SE 6, the definition of a server-class machine is one with at least 2 CPUs and at least 2GB of physical memory. )

    Update:

    I can only confirm that these options are also provided by java8(1.8.0_121). Not sure for java9 or later.

    0 讨论(0)
提交回复
热议问题