JVM参数简介

参考文档地址:https://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html#BGBCIEFC

-Xmnsize

Sets the initial and maximum size (in bytes) of the heap for the young generation (nursery). Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes.

设置新生代的堆的初始大小和最大大小(以字节为单位)。

The young generation region of the heap is used for new objects. GC is performed in this region more often than in other regions. If the size for the young generation is too small, then a lot of minor garbage collections will be performed. If the size is too large, then only full garbage collections will be performed, which can take a long time to complete. Oracle recommends that you keep the size for the young generation between a half and a quarter of the overall heap size.

新生代区域的堆用于新对象。与其他区域相比,在该区域执行GC的频率更高。如果新生代的大小太小,则会执行许多次要的垃圾回收。如果大小太大,那么将仅执行完整的垃圾收集,这可能需要很长时间才能完成。 Oracle建议您将新生代的大小保持在整个堆大小的一半到四分之一之间。

Instead of the -Xmn option to set both the initial and maximum size of the heap for the young generation, you can use -XX:NewSize to set the initial size and -XX:MaxNewSize to set the maximum size.

可以使用-XX:NewSize设置初始大小和-XX:MaxNewSize设置最大大小,代替-Xmn选项来设置新生代的堆的初始大小和最大大小。

-Xmssize

Sets the initial size (in bytes) of the heap. This value must be a multiple of 1024 and greater than 1 MB. Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes.

设置堆的初始大小(以字节为单位)。此值必须是1024的倍数且大于1 MB。

If you do not set this option, then the initial size will be set as the sum of the sizes allocated for the old generation and the young generation. The initial size of the heap for the young generation can be set using the -Xmn option or the -XX:NewSize option.

如果未设置此选项,则初始大小将设置为老年代和新生代分配的大小之和。

-Xmxsize

Specifies the maximum size (in bytes) of the memory allocation pool in bytes. This value must be a multiple of 1024 and greater than 2 MB. Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes. The default value is chosen at runtime based on system configuration. For server deployments, -Xms and -Xmx are often set to the same value.

指定内存分配池的最大大小(以字节为单位)。此值必须是1024的倍数且大于2 MB。默认值是在运行时根据系统配置选择的。对于服务器部署,-Xms和-Xmx通常设置为相同的值。

The -Xmx option is equivalent to -XX:MaxHeapSize.

Xmx选项等效于-XX:MaxHeapSize。

-Xsssize

Sets the thread stack size (in bytes). Append the letter k or K to indicate KB, m or M to indicate MB, g or G to indicate GB.

设置线程堆栈大小(以字节为单位)。

This option is equivalent to -XX:ThreadStackSize.

此选项等效于-XX:ThreadStackSize。

-XX:MinHeapFreeRatio=percent

Sets the minimum allowed percentage of free heap space (0 to 100) after a GC event. If free heap space falls below this value, then the heap will be expanded. By default, this value is set to 40%.

设置GC事件后允许的最小最小可用堆空间百分比(0到100)。如果可用堆空间低于此值,则将扩展堆。默认情况下,此值设置为40%。

-XX:MaxHeapFreeRatio=percent

Sets the maximum allowed percentage of free heap space (0 to 100) after a GC event. If free heap space expands above this value, then the heap will be shrunk. By default, this value is set to 70%.

设置GC事件后允许的最大可用堆空间百分比(0到100)。如果可用堆空间扩展到该值以上,则堆将缩小。默认情况下,此值设置为70%。

-XX:NewRatio=ratio

Sets the ratio between young and old generation sizes. By default, this option is set to 2.

设置新老一代大小之间的比率。默认情况下,此选项设置为2。

-XX:SurvivorRatio=ratio

Sets the ratio between eden space size and survivor space size.

设置伊甸园空间大小与幸存者空间大小之间的比率。

-XX:TargetSurvivorRatio=percent

Sets the desired percentage of survivor space (0 to 100) used after young garbage collection. By default, this option is set to 50%.

设置垃圾回收后所需的剩余空间百分比(0到100)。默认情况下,此选项设置为50%。

-XX:MetaspaceSize=size

Sets the size of the allocated class metadata space that will trigger a garbage collection the first time it is exceeded. This threshold for a garbage collection is increased or decreased depending on the amount of metadata used. The default size depends on the platform.

设置分配的类元数据空间的大小,该类元数据空间将在首次超过垃圾收集时触发。垃圾收集的阈值取决于使用的元数据量而增加或减少。默认大小取决于平台。

-XX:MaxMetaspaceSize=size

Sets the maximum amount of native memory that can be allocated for class metadata. By default, the size is not limited. The amount of metadata for an application depends on the application itself, other running applications, and the amount of memory available on the system.

设置可以分配给类元数据的最大本机内存。默认情况下,大小不受限制。应用程序的元数据量取决于应用程序本身,其他正在运行的应用程序以及系统上可用的内存量。

-XX:+UseTLAB

Enables the use of thread-local allocation blocks (TLABs) in the young generation space. This option is enabled by default. To disable the use of TLABs, specify -XX:-UseTLAB.

允许在年轻代空间中使用线程本地分配块(TLAB)。默认情况下启用此选项。要禁用TLAB,请指定-XX:-UseTLAB。

-XX:TLABSize=size

Sets the initial size (in bytes) of a thread-local allocation buffer (TLAB). Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes. If this option is set to 0, then the JVM chooses the initial size automatically.

设置线程本地分配缓冲区(TLAB)的初始大小(以字节为单位)。字母k或K表示千字节,m或M表示兆字节,g或G表示千兆字节。如果此选项设置为0,那么JVM将自动选择初始大小。

-XX:-UseCompressedOops

Disables the use of compressed pointers. By default, this option is enabled, and compressed pointers are used when Java heap sizes are less than 32 GB. When this option is enabled, object references are represented as 32-bit offsets instead of 64-bit pointers, which typically increases performance when running the application with Java heap sizes less than 32 GB. This option works only for 64-bit JVMs.

禁用压缩指针的使用。默认情况下,此选项处于启用状态,并且当Java堆大小小于32 GB时,将使用压缩指针。启用此选项后,对象引用将表示为32位偏移量而不是64位指针,这通常在运行Java堆大小小于32 GB的应用程序时提高性能。此选项仅适用于64位JVM。

It is also possible to use compressed pointers when Java heap sizes are greater than 32GB. See the -XX:ObjectAlignmentInBytes option.

当Java堆大小大于32GB时,也可以使用压缩指针。请参阅-XX:ObjectAlignmentInBytes选项。

-XX:+UseG1GC

Enables the use of the garbage-first (G1) garbage collector. It is a server-style garbage collector, targeted for multiprocessor machines with a large amount of RAM. It meets GC pause time goals with high probability, while maintaining good throughput. The G1 collector is recommended for applications requiring large heaps (sizes of around 6 GB or larger) with limited GC latency requirements (stable and predictable pause time below 0.5 seconds).

启用垃圾优先(G1)垃圾收集器的使用。它是一种服务器样式的垃圾收集器,适用于具有大量RAM的多处理器计算机。它极有可能满足GC暂停时间目标,同时保持良好的吞吐量。建议将G1收集器用于需要大堆(大小约为6 GB或更大)且GC延迟要求有限(稳定且可预测的暂停时间低于0.5秒)的应用程序。

By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM.

默认情况下,此选项是禁用的,并且将根据计算机的配置和JVM的类型自动选择收集器。

-XX:+UseSerialGC

Enables the use of the serial garbage collector. This is generally the best choice for small and simple applications that do not require any special functionality from garbage collection. By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM.

启用串行垃圾收集器的使用。对于不需要垃圾回收具有任何特殊功能的小型和简单应用程序,这通常是最佳选择。默认情况下,此选项是禁用的,并且将根据计算机的配置和JVM的类型自动选择收集器。

-XX:+UseParallelGC

Enables the use of the parallel scavenge garbage collector (also known as the throughput collector) to improve the performance of your application by leveraging multiple processors.

允许使用并行清除垃圾收集器(也称为吞吐量收集器)来利用多个处理器来提高应用程序的性能。

By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM. If it is enabled, then the -XX:+UseParallelOldGC option is automatically enabled, unless you explicitly disable it.

默认情况下,此选项是禁用的,并且将根据计算机的配置和JVM的类型自动选择收集器。如果已启用,则-XX:+ UseParallelOldGC选项将自动启用,除非您明确禁用它。

-XX:+UseParallelOldGC

Enables the use of the parallel garbage collector for full GCs. By default, this option is disabled. Enabling it automatically enables the -XX:+UseParallelGC option.

允许将并行垃圾收集器用于完整的GC。默认情况下,此选项是禁用的。自动启用它会启用-XX:+ UseParallelGC选项。

-XX:+UseParNewGC

Enables the use of parallel threads for collection in the young generation. By default, this option is disabled. It is automatically enabled when you set the -XX:+UseConcMarkSweepGC option. Using the -XX:+UseParNewGC option without the -XX:+UseConcMarkSweepGC option was deprecated in JDK 8.

允许在年轻一代中使用并行线程进行收集。默认情况下,此选项是禁用的。当您设置-XX:+ UseConcMarkSweepGC选项时,它将自动启用。在JDK 8中,在不使用-XX:+ UseConcMarkSweepGC选项的情况下使用-XX:+ UseParNewGC选项这种方式已过时。

-XX:ParallelGCThreads=threads

Sets the number of threads used for parallel garbage collection in the young and old generations. The default value depends on the number of CPUs available to the JVM.

设置年轻一代和老一代中用于并行垃圾回收的线程数。缺省值取决于JVM可用的CPU数量。

-XX:+UseConcMarkSweepGC

Enables the use of the CMS garbage collector for the old generation. Oracle recommends that you use the CMS garbage collector when application latency requirements cannot be met by the throughput (-XX:+UseParallelGC) garbage collector. The G1 garbage collector (-XX:+UseG1GC) is another alternative.

启用CMS垃圾收集器适用于旧版本。当吞吐量(-XX:+ UseParallelGC)垃圾收集器无法满足应用程序延迟要求时,Oracle建议您使用CMS垃圾收集器。 G1垃圾收集器(-XX:+ UseG1GC)是另一种选择。

By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM. When this option is enabled, the -XX:+UseParNewGC option is automatically set and you should not disable it, because the following combination of options has been deprecated in JDK 8: -XX:+UseConcMarkSweepGC -XX:-UseParNewGC.

默认情况下,此选项是禁用的,并且将根据计算机的配置和JVM的类型自动选择收集器。启用此选项后,将自动设置-XX:+ UseParNewGC选项,并且您不应禁用它,因为在JDK 8中不推荐使用以下选项组合:-XX:+ UseConcMarkSweepGC -XX:-UseParNewGC。

-XX:+CMSClassUnloadingEnabled

Enables class unloading when using the concurrent mark-sweep (CMS) garbage collector. This option is enabled by default. To disable class unloading for the CMS garbage collector, specify -XX:-CMSClassUnloadingEnabled.

使用并发标记扫描(CMS)垃圾收集器时,启用类卸载。默认情况下启用此选项。要为CMS垃圾收集器禁用类卸载,请指定-XX:-CMSClassUnloadingEnabled。

-XX:+UseCMSInitiatingOccupancyOnly

Enables the use of the occupancy value as the only criterion for initiating the CMS collector. By default, this option is disabled and other criteria may be used.

启用将占用值用作启动CMS收集器的唯一条件。默认情况下,此选项是禁用的,并且可以使用其他条件。

-XX:MaxTenuringThreshold=threshold

Sets the maximum tenuring threshold for use in adaptive GC sizing. The largest value is 15. The default value is 15 for the parallel (throughput) collector, and 6 for the CMS collector.

设置用于自适应GC大小调整的最大使用期限阈值。最大值为15。并行(吞吐量)收集器的默认值为15,而CMS收集器的默认值为6。

-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses

Enables invoking of concurrent GC by using the System.gc() request and unloading of classes during the concurrent GC cycle. This option is disabled by default and can be enabled only together with the -XX:+UseConcMarkSweepGC option.

通过使用System.gc()请求启用并发GC的调用,并在并发GC周期中卸载类。默认情况下,此选项是禁用的,并且只能与-XX:+ UseConcMarkSweepGC选项一起启用。

-XX:MaxGCPauseMillis=time

Sets a target for the maximum GC pause time (in milliseconds). This is a soft goal, and the JVM will make its best effort to achieve it. By default, there is no maximum pause time value.

设置最大GC暂停时间的目标(以毫秒为单位)。这是一个软目标,JVM将尽最大的努力来实现它。默认情况下,没有最大暂停时间值。

-XX:+UseAdaptiveSizePolicy

Enables the use of adaptive generation sizing. This option is enabled by default. To disable adaptive generation sizing, specify -XX:-UseAdaptiveSizePolicy and set the size of the memory allocation pool explicitly (see the -XX:SurvivorRatio option).

启用自适应生成大小调整。默认情况下启用此选项。要禁用自适应生成大小调整,请指定-XX:-UseAdaptiveSizePolicy并显式设置内存分配池的大小(请参阅-XX:SurvivorRatio选项)。

-XX:+DisableExplicitGC

Enables the option that disables processing of calls to System.gc(). This option is disabled by default, meaning that calls to System.gc() are processed. If processing of calls to System.gc() is disabled, the JVM still performs GC when necessary.

启用用于禁用对System.gc()的调用的处理的选项。默认情况下禁用此选项,这意味着将处理对System.gc()的调用。如果禁用了对System.gc()的调用处理,则JVM在必要时仍会执行GC。

-XX:+PrintGCDetails

Enables printing of detailed messages at every GC. By default, this option is disabled.

启用在每个GC上打印详细消息的功能。默认情况下,此选项是禁用的。

-XX:+PrintTenuringDistribution

Enables printing of tenuring age information. The following is an example of the output:

启用打印Survivor区中对象年龄信息。以下是输出示例:

Age 1 objects are the youngest survivors (they were created after the previous scavenge, survived the latest scavenge, and moved from eden to survivor space). Age 2 objects have survived two scavenges (during the second scavenge they were copied from one survivor space to the next). And so on.

1岁年龄段的对象是最年轻的幸存者(它们是在前一次清理之后创建的,在最新清理之后幸存下来,并从伊甸园转移到幸存者空间)。 2岁年龄段的对象幸存了两次清理工作(在第二次清理工作中,将它们从一个幸存者空间复制到了另一个幸存者空间)。等等。

By default, this option is disabled.

默认情况下,此选项是禁用的。

-Xnoclassgc

Disables garbage collection (GC) of classes. This can save some GC time, which shortens interruptions during the application run.

禁用类的垃圾收集(GC)。这样可以节省一些GC时间,从而缩短了应用程序运行期间的中断时间。

When you specify -Xnoclassgc at startup, the class objects in the application will be left untouched during GC and will always be considered live. This can result in more memory being permanently occupied which, if not used carefully, will throw an out of memory exception.

当您在启动时指定-Xnoclassgc时,应用程序中的类对象在GC期间将保持不变,并且始终被认为是活动的。这可能会导致更多的内存被永久占用,如果不谨慎使用,将抛出内存不足异常。

-XX:+HeapDumpOnOutOfMemoryError

Enables the dumping of the Java heap to a file in the current directory by using the heap profiler (HPROF) when a java.lang.OutOfMemoryError exception is thrown. You can explicitly set the heap dump file path and name using the -XX:HeapDumpPath option. By default, this option is disabled and the heap is not dumped when an OutOfMemoryError exception is thrown.

引发java.lang.OutOfMemoryError异常时,使用堆分析器(HPROF)启用将Java堆转储到当前目录中的文件的功能。您可以使用-XX:HeapDumpPath选项显式设置堆转储文件的路径和名称。默认情况下,禁用此选项,并且在抛出OutOfMemoryError异常时不转储堆。

-XX:HeapDumpPath=path

Sets the path and file name for writing the heap dump provided by the heap profiler (HPROF) when the -XX:+HeapDumpOnOutOfMemoryError option is set. By default, the file is created in the current working directory, and it is named java_pidpid.hprof where pid is the identifier of the process that caused the error.

设置-XX:+ HeapDumpOnOutOfMemoryError选项时,设置用于写入由堆分析器(HPROF)提供的堆转储的路径和文件名。默认情况下,该文件是在当前工作目录中创建的,它的名称为java_pidpid.hprof,其中pid是引起错误的进程的标识符。

-XX:+UseLargePages

Enables the use of large page memory. By default, this option is disabled and large page memory is not used.

启用大页面内存的使用。默认情况下,此选项是禁用的,并且不使用大页面内存。

-XX:SoftRefLRUPolicyMSPerMB=time

Sets the amount of time (in milliseconds) a softly reachable object is kept active on the heap after the last time it was referenced. The default value is one second of lifetime per free megabyte in the heap. The -XX:SoftRefLRUPolicyMSPerMB option accepts integer values representing milliseconds per one megabyte of the current heap size (for Java HotSpot Client VM) or the maximum possible heap size (for Java HotSpot Server VM). This difference means that the Client VM tends to flush soft references rather than grow the heap, whereas the Server VM tends to grow the heap rather than flush soft references. In the latter case, the value of the -Xmx option has a significant effect on how quickly soft references are garbage collected.

设置在最后一次引用之后,软可访问对象在堆上保持活动状态的时间(以毫秒为单位)。缺省值是堆中每个空闲兆字节的生命周期的一秒钟。 -XX:SoftRefLRUPolicyMSPerMB选项接受整数值,该整数值表示当前堆大小(对于Java HotSpot客户端VM)或最大可能堆大小(对于Java HotSpot Server VM)每1兆字节毫秒。这种差异意味着客户端VM倾向于刷新软引用而不是增大堆,而服务器VM倾向于增大堆而不是刷新软引用。在后一种情况下,-Xmx选项的值对软引用被垃圾收集的速度有很大影响。

-XX:+UseFastAccessorMethods

Use optimized versions of GetField.

使用Get Field的优化版本。

-XX:+PrintCommandLineFlags

Enables printing of ergonomically selected JVM flags that appeared on the command line. It can be useful to know the ergonomic values set by the JVM, such as the heap space size and the selected garbage collector. By default, this option is disabled and flags are not printed.

启用打印在命令行上出现的按人体工程学选择的JVM标志。了解JVM设置的人体工程学值(例如堆空间大小和选定的垃圾收集器)可能会很有用。默认情况下,此选项为禁用状态,并且不打印标志。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值