Java 8中的默认Xmxsize(最大堆大小) [英] Default Xmxsize in Java 8 (max heap size)
问题描述
在 oracle文档中,我发现:
-Xmxsize以字节为单位指定内存分配池的最大大小(以字节为单位)...默认值 值是在运行时根据系统配置选择的.
-Xmxsize Specifies the maximum size (in bytes) of the memory allocation pool in bytes ... The default value is chosen at runtime based on system configuration.
系统配置是什么意思?
推荐答案
它取决于实现和版本,但通常取决于所使用的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
它提供了一个很长的列表,-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.
这篇关于Java 8中的默认Xmxsize(最大堆大小)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!