Skip to content

Latest commit

 

History

History
325 lines (288 loc) · 15.3 KB

vm-options.md

File metadata and controls

325 lines (288 loc) · 15.3 KB

JetBrains - VM Options

IDEs

  • CLion
  • IntelliJ IDEA
  • PhpStorm
  • PyCharm
  • ……

How to Edit

  • Menu BarHelpEdit Custom VM Options…

File Path

  • IntelliJ IDEA : /Users/[USERNAME]/Library/Application Support/JetBrains/IntelliJIdea2020.1/idea.vmoptions

References

Explanation

  • -Xms size 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.
  • -Xmx size Specifies the maximum size (in bytes) of the memory allocation pool.
    • It is equivalent to -XX:MaxHeapSize.
    • The default value is chosen at runtime based on system configuration.
    • For server deployments, -Xms and -Xmx are often set to the same value.
  • -XX:+UseConcMarkSweepGC Enables the use of the CMS garbage collector for the old generation.
    • CMS is an alternative to the default garbage collector (G1), which also focuses on meeting application latency requirements.
    • By default, this option is disabled and the collector is selected automatically based on the configuration of the machine and type of the JVM.
    • The CMS garbage collector is deprecated.
  • -XX:+UseParNewGC Enables the use of parallel threads for collection in the young generation.
    • By default, this option is disabled.
    • It's automatically enabled when you set the -XX:+UseConcMarkSweepGC option.
    • Using the -XX:+UseParNewGC option without the -XX:+UseConcMarkSweepGC option was deprecated in JDK 8.
    • All uses of the -XX:+UseParNewGC option are deprecated.
    • Using the option without -XX:+UseConcMarkSweepGC isn't possible.
  • -XX:+UseCompressedOops Enable 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 of less than 32 GB.
    • This option works only for 64-bit JVMs.
  • -XX:+HeapDumpOnOutOfMemoryError Enables dumping 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 isn't dumped when an OutOfMemoryError exception is thrown.
  • -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's named java_pid<pid>.hprof where <pid> is the identifier of the process that caused the error.
    • The following example shows how to set the default file explicitly ( %p represents the current process identifier ) :
      • -XX:HeapDumpPath=./java_pid%p.hprof
  • -XX:-OmitStackTraceInFastThrow
  • -XX:CICompilerCount=threads Sets the number of compiler threads to use for compilation.
    • By default, the number of threads is set to 2 for the server JVM, to 1 for the client JVM, and it scales to the number of cores if tiered compilation ( 分层编译 ) is used.
    • The following example shows how to set the number of threads to 2 : -XX:CICompilerCount=2
  • -XX:ErrorFile=filename Specifies the path and file name to which error data is written when an irrecoverable error occurs.
    • By default, this file is created in the current working directory and named hs_err_pidpid.log where pid is the identifier of the process that caused the error.
  • -XX:ReservedCodeCacheSize=size Sets the maximum code cache size (in bytes) for JIT-compiled code.
    • The default maximum code cache size is 240 MB, unless you disable tiered compilation with the option -XX:-TieredCompilation, then the default size is 48 MB.
    • This option has a limit of 2 GB; otherwise, an error is generated.
    • The maximum code cache size shouldn't be less than the initial code cache size.
    • See the option -XX:InitialCodeCacheSize.
  • -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.
  • -Xverify:none Disables the verifier.
  • -Dfile.encoding=UTF-8
  • -Djava.net.preferIPv4Stack=true To enforce IPv4 preference over IPv6.
  • -Djdk.attach.allowAttachSelf
  • -Djdk.http.auth.tunneling.disabledSchemes="" To re-enable basic authentication for Proxy.
  • -Dkotlinx.coroutines.debug=off
  • -Dsun.io.useCanonPrefixCache=false Disable Java's canonicalization cache.
  • -ea Enables assertions.
    • Synopsis : -enableassertions[:[packagename]...|:classname] or -ea[:[packagename]...|:classname]
      • By default, assertions are disabled in all packages and classes.
      • With no arguments, -enableassertions (-ea) enables assertions in all packages and classes.
      • With the packagename argument ending in ..., the switch enables assertions in the specified package and any subpackages.
      • If the argument is simply ..., then the switch enables assertions in the unnamed package in the current working directory.
      • With the classname argument, the switch enables assertions in the specified class.
    • The -enableassertions (-ea) option applies to all class loaders and to system classes (which don't have a class loader).
      • There's one exception to this rule :
        • If the option is provided with no arguments, then it doesn't apply to system classes.
      • This makes it easy to enable assertions in all classes except for system classes.
      • The -enablesystemassertions option provides a separate switch to enable assertions in all system classes.
      • To explicitly disable assertions in specific packages or classes, use the -disableassertions (-da) option.
      • If a single command contains multiple instances of these switches, then they're processed in order, before loading any classes.
    • For example, to run the MyClass application with assertions enabled only in the package com.wombat.fruitbat (and any subpackages) but disabled in the class com.wombat.fruitbat.Brickbat, use the following command:
      • java -ea:com.wombat.fruitbat... -da:com.wombat.fruitbat.Brickbat MyClass

Versions

CMS

before 2019-09

  • -XX:+UseConcMarkSweepGC
-Xms1024m
-Xmx1024m
-XX:+UseConcMarkSweepGC
-XX:+UseCompressedOops
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:CICompilerCount=2
-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-XX:ReservedCodeCacheSize=240m
-XX:SoftRefLRUPolicyMSPerMB=50
-Xverify:none
-Dfile.encoding=UTF-8
-Djava.net.preferIPv4Stack=true
-Djdk.attach.allowAttachSelf
-Djdk.http.auth.tunneling.disabledSchemes=""
-Dkotlinx.coroutines.debug=off
-Dsun.io.useCanonPrefixCache=false
-ea

ParNew + CMS

2021-08-06 from a forum

  • -XX:+UseParNewGC
  • -XX:+UseConcMarkSweepGC
-Xms6144m
-Xmx6144m
-Xmn2048m
-XX:PermSize=512m
-XX:MaxPermSize=768m
-Xss512K
-XX:ReservedCodeCacheSize=256m
-XX:SurvivorRatio=1
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+UseCMSCompactAtFullCollection
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=70
-XX:+CMSParallelRemarkEnabled
-XX:+CMSClassUnloadingEnabled
-XX:CMSFullGCsBeforeCompaction=0
-XX:LargePageSizeInBytes=200M
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Dsun.rmi.dgc.client.gcInterval=10800000
-Dsun.rmi.dgc.server.gcInterval=10800000
-XX:SoftRefLRUPolicyMSPerMB=0
-XX:+DisableExplicitGC
-XX:+PrintClassHistogram
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintHeapAtGC

-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-Xbootclasspath/a:../lib/boot.jar
-XX:MaxPermSize=512m

ZGC Trial

2020-09-03

  • -XX:+UseConcMarkSweepGC
  • -XX:+UseZGC
-Xms1024m
-Xmx1024m
-XX:+UnlockExperimentalVMOptions
-XX:+UseZGC
-XX:+UseCompressedOops
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:CICompilerCount=2
-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-XX:ReservedCodeCacheSize=240m
-XX:SoftRefLRUPolicyMSPerMB=50
-Xverify:none
-Dfile.encoding=UTF-8
-Djava.net.preferIPv4Stack=true
-Djdk.attach.allowAttachSelf
-Djdk.http.auth.tunneling.disabledSchemes=""
-Dkotlinx.coroutines.debug=off
-Dsun.io.useCanonPrefixCache=false
-ea

ZGC Ver.1

2020-09-04

  • -XX:+UseG1GC
-Xms1024m
-Xmx1024m
-XX:+UseG1GC
-XX:+UseCompressedOops
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:CICompilerCount=2
-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-XX:ReservedCodeCacheSize=240m
-XX:SoftRefLRUPolicyMSPerMB=50
-Xverify:none
-Dfile.encoding=UTF-8
-Djava.net.preferIPv4Stack=true
-Djdk.attach.allowAttachSelf
-Djdk.http.auth.tunneling.disabledSchemes=""
-Dkotlinx.coroutines.debug=off
-Dsun.io.useCanonPrefixCache=false
-ea

IntelliJ IDEA Ultimate Default

2021-08-06 from JetBrains IDE - IntelliJ IDEA Ultimate

  • -XX:+UseG1GC
-Xms128m
-Xmx2048m
-XX:ReservedCodeCacheSize=512m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-ea
-Dsun.io.useCanonCaches=false
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-Dide.no.platform.update=true
-Dtoolbox.notification.token=[SECRET]
-Dtoolbox.notification.portFile=[SECRET]

ZGC Ver.2

2021-08-06

-ea
-Xms6144m
-Xmx6144m
-XX:+UseG1GC
-XX:+UseCompressedOops
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:CICompilerCount=2
-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
-XX:ReservedCodeCacheSize=512m
-XX:SoftRefLRUPolicyMSPerMB=50
-Xverify:none
-Dfile.encoding=UTF-8
-Dide.no.platform.update=true
-Djava.net.preferIPv4Stack=true
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-Dkotlinx.coroutines.debug=off
-Dsun.io.useCanonCaches=false
-Dsun.io.useCanonPrefixCache=false
-Dtoolbox.notification.token=[SECRET]
-Dtoolbox.notification.portFile=[SECRET]

ZGC Current

File : .idea.vmoptions