Real differences between “java -server” and “java -client”?

前端 未结 11 2126
旧时难觅i
旧时难觅i 2020-11-22 03:52

Is there any real practical difference between \"java -server\" and \"java -client\"?

All I can find on Sun\'s site is a vague

\"-server st

11条回答
  •  -上瘾入骨i
    2020-11-22 04:46

    The most visible immediate difference in older versions of Java would be the memory allocated to a -client as opposed to a -server application. For instance, on my Linux system, I get:

    $ java -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version'
    uintx AdaptivePermSizeWeight               = 20               {product}
    uintx ErgoHeapSizeLimit                    = 0                {product}
    uintx InitialHeapSize                     := 66328448         {product}
    uintx LargePageHeapSizeThreshold           = 134217728        {product}
    uintx MaxHeapSize                         := 1063256064       {product}
    uintx MaxPermSize                          = 67108864         {pd product}
    uintx PermSize                             = 16777216         {pd product}
    java version "1.6.0_24"
    

    as it defaults to -server, but with the -client option I get:

    $ java -client -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version'
    uintx AdaptivePermSizeWeight               = 20               {product}
    uintx ErgoHeapSizeLimit                    = 0                {product}
    uintx InitialHeapSize                     := 16777216         {product}
    uintx LargePageHeapSizeThreshold           = 134217728        {product}
    uintx MaxHeapSize                         := 268435456        {product}
    uintx MaxPermSize                          = 67108864         {pd product}
    uintx PermSize                             = 12582912         {pd product}
    java version "1.6.0_24"
    

    so with -server most of the memory limits and initial allocations are much higher for this java version.

    These values can change for different combinations of architecture, operating system and jvm version however. Recent versions of the jvm have removed flags and re-moved many of the distinctions between server and client.

    Remember too that you can see all the details of a running jvm using jvisualvm. This is useful if you have users who or modules which set JAVA_OPTS or use scripts which change command line options. This will also let you monitor, in real time, heap and permgen space usage along with lots of other stats.

提交回复
热议问题