Skip to content

Instantly share code, notes, and snippets.

@mahmoudimus
Last active February 19, 2024 15:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mahmoudimus/ce9278d27267e109dda7292cfa1ba253 to your computer and use it in GitHub Desktop.
Save mahmoudimus/ce9278d27267e109dda7292cfa1ba253 to your computer and use it in GitHub Desktop.
A running timeline of my IntelliJ on Steroids with GC tuning
-ea
-server
-Xss256k
-Xms4G
-Xmx4G
-XX:+IgnoreUnrecognizedVMOptions
-XX:+UnlockExperimentalVMOptions
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:-UseSerialGC
-XX:-UseParallelGC
-XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:G1PeriodicGCInterval=900k -XX:G1PeriodicGCSystemLoadThreshold=0.3 -XX:+ParallelRefProcEnabled -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem XX:MaxTenuringThreshold=1
-XX:ReservedCodeCacheSize=1G
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:+UseStringCache
-XX:+UseStringDeduplication
-XX:+AggressiveOpts
-XX:+AlwaysPreTouch
-XX:+OptimizeStringConcat
-XX:+UseFastAccessorMethods
-Dide.no.platform.update=true
-Djava.net.preferIPv4Stack=true
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-Dsun.io.useCanonCaches=false
-Dsun.java2d.d3d=false
-Dsun.java2d.metal=true
-Dsun.java2d.opengl=false
-Dsun.tools.attach.tmp.only=true
-Dsun.awt.mac.a11y.enabled=false
--add-exports=java.desktop/com.apple.eawt.event=ALL-UNNAMED
--add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED
--add-exports=java.desktop/com.apple.laf=ALL-UNNAMED
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED
--add-exports=java.desktop/sun.font=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.nio.charset=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED
--add-opens=java.base/java.time=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.vm=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.desktop/com.apple.eawt.event=ALL-UNNAMED
--add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED
--add-opens=java.desktop/com.apple.laf=ALL-UNNAMED
--add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED
--add-opens=java.desktop/java.awt.event=ALL-UNNAMED
--add-opens=java.desktop/java.awt.image=ALL-UNNAMED
--add-opens=java.desktop/java.awt.peer=ALL-UNNAMED
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.datatransfer=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED
--add-opens=java.desktop/sun.awt=ALL-UNNAMED
--add-opens=java.desktop/sun.font=ALL-UNNAMED
--add-opens=java.desktop/sun.java2d=ALL-UNNAMED
--add-opens=java.desktop/sun.lwawt.macosx=ALL-UNNAMED
--add-opens=java.desktop/sun.lwawt=ALL-UNNAMED
--add-opens=java.desktop/sun.swing=ALL-UNNAMED
--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED
--add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
--add-opens=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED
-Dide.no.platform.update=true
-Dtoolbox.notification.token=WJ5YnocMtfGEiTcIw21QBXu9v_rgz7FoGlPUtkFQHQs=
-Dtoolbox.notification.portFile=C:\Users\Default User.DESKTOP-V01B6SV\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\222.3345.118.vmoptions.port
-Didea.plugins.path=C:\\Users\\Default User.DESKTOP-V01B6SV\\AppData\\Local\\JetBrains\\Toolbox\\apps\\IDEA-U\\ch-0\\222.3345.118.plugins
-ea
-server
-Xms1024m
-Xmx5120m
-XX:+UnlockExperimentalVMOptions
-XX:+UseZGC
-XX:+IgnoreUnrecognizedVMOptions
-XX:+TieredCompilation
-XX:+UseDynamicNumberOfGCThreads
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:ReservedCodeCacheSize=512m
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:+UseStringCache
-XX:+UseStringDeduplication
-XX:+AggressiveOpts
-XX:+AlwaysPreTouch
-XX:+OptimizeStringConcat
-XX:+UseFastAccessorMethods
-Dide.no.platform.update=true
-Djava.net.preferIPv4Stack=true
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-Dsun.io.useCanonCaches=false
-Dsun.tools.attach.tmp.only=true
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED
--add-exports=java.desktop/sun.font=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.nio.charset=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED
--add-opens=java.base/java.time=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.vm=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED
--add-opens=java.desktop/java.awt.event=ALL-UNNAMED
--add-opens=java.desktop/java.awt.image=ALL-UNNAMED
--add-opens=java.desktop/java.awt.peer=ALL-UNNAMED
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.datatransfer=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED
--add-opens=java.desktop/sun.awt=ALL-UNNAMED
--add-opens=java.desktop/sun.font=ALL-UNNAMED
--add-opens=java.desktop/sun.java2d=ALL-UNNAMED
--add-opens=java.desktop/sun.lwawt.macosx=ALL-UNNAMED
--add-opens=java.desktop/sun.lwawt=ALL-UNNAMED
--add-opens=java.desktop/sun.swing=ALL-UNNAMED
--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED
--add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
--add-opens=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED
-ea
-server
-Xms1024m
-Xmx5120m
-Xss256k
-XX:+UnlockExperimentalVMOptions
-XX:-UseSerialGC
-XX:-UseParallelGC
-XX:-UseG1GC
-XX:+UseZGC
-XX:TieredCompilation
-XX:UseDynamicNumberOfGCThreads
-XX:+IgnoreUnrecognizedVMOptions
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:ReservedCodeCacheSize=512m
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:+UseStringCache
-XX:+UseStringDeduplication
-XX:+AggressiveOpts
-XX:+AlwaysPreTouch
-XX:+OptimizeStringConcat
-XX:+UseFastAccessorMethods
-Dide.no.platform.update=true
-Djava.net.preferIPv4Stack=true
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-Dsun.io.useCanonCaches=false
-Dsun.java2d.d3d=false
-Dsun.java2d.metal=true
-Dsun.java2d.opengl=false
-Dsun.tools.attach.tmp.only=true
-Dsun.awt.mac.a11y.enabled=false
--add-exports=java.desktop/com.apple.eawt.event=ALL-UNNAMED
--add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED
--add-exports=java.desktop/com.apple.laf=ALL-UNNAMED
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED
--add-exports=java.desktop/sun.font=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.nio.charset=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED
--add-opens=java.base/java.time=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.vm=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.desktop/com.apple.eawt.event=ALL-UNNAMED
--add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED
--add-opens=java.desktop/com.apple.laf=ALL-UNNAMED
--add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED
--add-opens=java.desktop/java.awt.event=ALL-UNNAMED
--add-opens=java.desktop/java.awt.image=ALL-UNNAMED
--add-opens=java.desktop/java.awt.peer=ALL-UNNAMED
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.datatransfer=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.windows=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED
--add-opens=java.desktop/sun.awt=ALL-UNNAMED
--add-opens=java.desktop/sun.font=ALL-UNNAMED
--add-opens=java.desktop/sun.java2d=ALL-UNNAMED
--add-opens=java.desktop/sun.lwawt.macosx=ALL-UNNAMED
--add-opens=java.desktop/sun.lwawt=ALL-UNNAMED
--add-opens=java.desktop/sun.swing=ALL-UNNAMED
--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED
--add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
--add-opens=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED
-ea
-server
-Xms1024m
-Xmx4096m
-Xss256k
-XX:-UseSerialGC
-XX:-UseParallelGC
-XX:+UseG1GC
-XX:+UseStringCache
-XX:+UseStringDeduplication
-XX:ReservedCodeCacheSize=240m
-XX:+AggressiveOpts
-XX:PermSize=64m
-XX:MaxPermSize=512m
-XX:MaxGCPauseMillis=200
-XX:ParallelGCThreads=10
-XX:ConcGCThreads=7
-XX:InitiatingHeapOccupancyPercent=85
-XX:SoftRefLRUPolicyMSPerMB=1000
-XX:CompileThreshold=5000
-Dfile.encoding=UTF-8
-Djava.net.preferIPv4Stack=true
-Dsun.io.useCanonCaches=false
-Dkotlinx.coroutines.debug=off
-Dsun.awt.mac.a11y.enabled=false

JVM Memory

image

-XX:+UnlockDiagnosticVMOptions 
-XX:+PrintFlagsFinal 
-XX:+PrintGCDetails
-Xlog:gc+heap
-XX:+HeapDumpOnOutOfMemoryError

-XX:+UseSerialGC
-XX:+UseParallelGC
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC 
-XX:+UseG1GC
-XX:+UseShenandoahGC
-XX:+UseZGC
-XX:+UseEpsilonGC 

-XX:MinRAMPercentage
-XX:MaxRAMPercentage-Xms
-Xmx
-XX:-AdaptiveSizePolicy

-XX:MetaspaceSize
-XX:MaxMetaspaceSize
-XX:MinMetaspaceFreeRatio
-XX:MaxMetaspaceFreeRatio

-n jvmJavaOSStackSize
-Xss
-XX:VmThreadStackSize
-XX:CompilerThreadStackSize

-XX:+PrintGCDetails 
-XX:+TraceClassUnloading 
-XX:+TraceClassLoading
-XX:CompressedClassSpaceSize
-XX:-UseCompressedClassPointers

-XX:+PrintStringTableStatistics
-XX:StringTableSize
-XX:+UseStringDeduplication

-XX:+PrintCodeCache
-XX:InitialCodeCacheSize
-XX:ReservedCodeCacheSize 
-XX:CodeCacheExpansionSize 

-n jvmNativeStackSize 

-XX:MaxDirectMemorySize

-XX:NativeMemoryTracking=off | summary | detail  
-XX:+PrintNMTStatistics 
-XX:-AutoShutdownNMT

-XX:+PrintCompilation

-XX:+UnlockDiagnosticVMOptions 
-XX:+LogCompilation
-XX:+PrintFlagsFinal

-XX:CICompilerCount
-XX:CompileThresholdn
-XX:-TieredCompilation

-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.port=9099 
-Dcom.sun.management.jmxremote.rmi.port=9099 
-Dcom.sun.management.jmxremote.local.only=false 
-Djava.rmi.server.hostname=0.0.0.0 
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000

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

-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]
@mahmoudimus
Copy link
Author

mahmoudimus commented Apr 20, 2022

# -XX:+UseShenandoahGC
# -XX:ParallelGCThreads=4
# -XX:ConcGCThreads=4
# -XX:ShenandoahUncommitDelay=1000
# -XX:ShenandoahGuaranteedGCInterval=10000
# -XX:ShenandoahGCHeuristics=compact -XX:MaxRAMPercentage=50.0 -XX:+DisableExplicitGC

@joshuataylor
Copy link

Holy moly!

Thank you so much for documenting what the settings actually do, as turning random knobs and flicking random switches is a bit daunting, especially as certain options aren't relevant anymore.

Once again -- THANK YOU!

@joshuataylor
Copy link

joshuataylor commented Apr 13, 2023

On my M1 Mac, using -Dsun.java2d.metal.displaySync=false improves performance alongside Metal.

@joshuataylor
Copy link

Other flags of note (using this as a dumping ground of notes for myself and others):

Linux: -XX:+UseLargePages https://www.oracle.com/java/technologies/javase/largememory-pages.html
Am playing with this, my kernel is compiled with support. Seems great so far. Need to play more with XX:-UseLargePagesIndividualAllocation.

Flags I'm experimenting with, on both Macbook Air M1 + Linux desktop:
-XX:MaxInlineLevel=xxx
XXX being a number.

The value controls the maximum depth of method inlining performed by the JIT compiler in the JVM.

By default, the JVM inlines methods up to a certain depth, which by default is 9. IMHO, playing with this value would be worth while.

Trying from this thread, see another here, though that's not IntellIJ. Also see https://bugs.openjdk.org/browse/JDK-8234863

These will also need to be played with:
-XX:InlineSmallCode (Default value: Enabled)
This parameter enables or disables the inlining of small methods. Inlining is a compiler optimization technique that replaces a method call with the actual code of the method being called.

-XX:MaxInlineSize (Default value: 35)
This parameter sets the maximum bytecode size of a method that can be inlined. If the size of a method exceeds this limit, it will not be inlined.

-XX:MinInliningThreshold (Default value: 2500)
This parameter sets the minimum number of invocations of a method before it becomes a candidate for inlining.

-XX:FreqInlineSize (Default value: 325)
This parameter sets the maximum bytecode size of a frequently called method that can be inlined. A frequently called method is a method that is called more often than the minimum inlining threshold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment