更新时间:2023-09-12 23:42:40
它因实现和版本而异,但通常取决于所使用的 VM(例如客户端或服务器,参见 -client
和 -server
参数)和您的系统内存.
It varies on implementation and version, but usually it depends on the VM used (e.g. client or server, see -client
and -server
parameters) and on your system memory.
通常client
的默认值是物理内存的 1/4 或 1GB(以较小者为准).
Often for client
the default value is 1/4th of your physical memory or 1GB (whichever is smaller).
Java 配置选项(命令行参数)也可以外包"给环境变量,包括 -Xmx
,它可以更改默认值(意味着指定新的默认值).特别是 JAVA_TOOL_OPTIONS
环境变量由所有 Java 工具检查并在存在时使用(更多详细信息 这里 和 此处).
Also Java configuration options (command line parameters) can be "outsourced" to environment variables including the -Xmx
, which can change the default (meaning specify a new default). Specifically the JAVA_TOOL_OPTIONS
environment variable is checked by all Java tools and used if exists (more details here and here).
您可以运行以下命令查看默认值:
You can run the following command to see default values:
java -XX:+PrintFlagsFinal -version
它给你一个loooong列表,-Xmx
在MaxHeapSize
中,-Xms
在InitialHeapSize
中.过滤您的输出(例如 Linux 上的 |grep
)或将其保存在一个文件中,以便您可以在其中进行搜索.
It gives you a loooong list, -Xmx
is in MaxHeapSize
, -Xms
is in InitialHeapSize
. Filter your output (e.g. |grep
on linux) or save it in a file so you can search in it.