Java选项-Xmx代表什么?

rav*_*avi 248 java

java -Xmx1024m filename

什么-Xmx意思?

Nis*_*ant 282

看到这里:Java Tool Doc,它说,

-Xmx n
指定内存分配池的最大大小(以字节为单位).此值必须是1024的倍数大于2MB.附加字母k或K表示千字节,或m或M表示兆字节.默认值为64MB.此值的上限在Solaris 7和Solaris 8 SPARC平台上约为4000米,在Solaris 2.6和x86平台上为2000米,减去开销金额.例子:

           -Xmx83886080
           -Xmx81920k
           -Xmx80m
Run Code Online (Sandbox Code Playgroud)

因此,简单来说,您将Java堆内存设置为可用内存最多1024 MB,而不是更多.

请注意,-Xmx和1024m之间没有空格

如果使用大写或小写,则无关紧要.例如:"-Xmx10G"和"-Xmx10g"完全相同.

  • 这有点误导.Xmx和Xms的值不是JVM使用的内存的总大小 - 仅限于*heap*.请参阅typo.pl的答案 (23认同)
  • ..并添加后缀"G"或"g"表示技嘉:) (16认同)
  • 我希望找到X的含义,因为我正在寻找-XX代表的东西.捷径意味着什么.... (2认同)
  • 值得注意的是,如果您希望所有java进程全局拾取-X参数,您可以设置JAVA_TOOL_OPTIONS环境变量,例如export JAVA_TOOL_OPTIONS =“-Xmx6g”[http://stackoverflow.com/questions/17781405/关于java选项的信息]和[http://stackoverflow.com/questions/28327620/difference- Between-java-options-java-tool-options-and-java-opts] (2认同)

typ*_*.pl 142

C:\java -X

    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by ;>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by ;>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by ;>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni       perform additional checks for JNI functions
    -Xshare:off       do not attempt to use shared class data
    -Xshare:auto      use shared class data if possible (default)
    -Xshare:on        require using shared class data, otherwise fail.

The -X options are non-standard and subject to change without notice.
Run Code Online (Sandbox Code Playgroud)

  • 人们应该真正开始阅读精美的手册......谢谢! (9认同)
  • 是的,那些1行描述是绝对彻底的,涵盖了一切.这就是没有人需要StackOverflow的原因.如果他们让你对个别论点做出帮助并且看看更详细地设置这些参数的含义,那么可能不会那么糟糕,因此命令参数的手册页等等. (8认同)

Ale*_*øld 16

-Xmx选项更改VM的最大堆空间.java -Xmx1024m表示VM最多可以分配1024 MB.通俗地说,这意味着应用程序最多可以使用1024MB内存.


Kan*_*j M 13

应用程序的最大堆使用率为1024 MB


Clo*_*ble 5

-Xmx 设置最大堆大小