Skip to content

HotSpot JVM Arguments

July 11, 2013

The HotSpot JVM has many arguments, and knowing what they are is important to use the JVM to it’s full potential.

The documentation alone, doesn’t quite cover all the necessary details or what every option does, especially extra options (-X) and experimental options (-XX). Nearly all of these options are specific to HotSpot and not in the JVM Specification itself. But since many run on Oracle/OpenJDK (HotSpot), it’s worth knowing what options are available.

The best way to find all of these options and understand what they do is by looking at the source code. For this blog post, I’ll be focusing on the OpenJDK 8 version (as of this writing b98).

Arguments.cpp has a method named “Arguments::parse_each_vm_init_arg” which handles all the JVM arguments. But the method that starts the entire process is “Arguments::parse_vm_init_args”

The options and what they do are described in a table below: 

By default, HotSpot does the following:

  1. Always compile loop methods
  2. UseOnStackReplacement
  3. ClipInlining
  4. And JIT Background Compilation
  • -verbose
    • :class (default) – TraceClassLoading and TraceClassUnloading are enabled.
    • :gc – PrintGC
    • :jni – PrintJNIResolving
  • User assertions: -da (disable), -ea (enable), -disableassertions, -enableassertions. Ex. -ea:class|package
  • System assertions: -dsa (disable), -esa (enable), -disablesystemassertions, -enablesystemassertions
  • -Xbootclasspath: – reset the path
  • -Xbootclasspath/a: – for suffix
  • -Xbootclasspath/p: – for prefix
  • -Xrun – adds a library for profiling and debugging
  • -agentlib / -agentpath – add an agent via JVMTI
  • -javaagent – creates an instrumentation agent
  • -Xnoclassgc – set ClassUnloading=false
  • -Xincgc – UseConcMarkSweepGC=true and CMSIncrementalMode=true
  • -Xnoincgc – UseConcMarkSweepGC=false and CMSIncrementalMode=false
  • -Xconcgc – UseConcMarkSweepGC=true
  • -Xnoconcgc – UseConcMarkSweepGC=false
  • -Xbatch – disable BackgroundCompilation (JIT) basically run in interpreted mode.
  • -Xmn – set initial Eden memory size. Sets the MaxNewSize and NewSize to this value.
  • -Xms – initial heap size, also minimum heap size.
  • -Xmx or -XX:MaxHeapSize= – sets MaxHeapSize.
  • -Xmaxf – a decimal number between 0.0 and 1.0 for the MaxHeapFreeRatio
  • -Xminf – a decimal number between 0.0 and 1.0 for the MinHeapFreeRatio
  • -Xss – sets ThreadStackSize
  • -Xoss (not used) because HotSpot does not have separate native and Java stacks.
  • -XX:CodeCacheExpansionSize= – This cache is a memory area separate from the JVM heap that contains all the JVM bytecode for a method compiled down to native code, each called an nmethod. This is where the JIT compiled methods are kept.
  • -Xmaxjitcodesize or -XX:ReservedCodeCacheSize= – code cache size.
    • -XX:IncreaseFirstTierCompileThresholdAt= – between 0 and 99
  • -green (not used) – java does not have green threads even if you want them.
  • -native (not used) – java threads are always native
  • -Xsqnopause – ignored silently
  • -Xrs – ReduceSignalUsage – With this option fewer signals are used, although the VM installs its own signal handler for essential signals such as SIGSEGV.
  • -Xusealtsigs – UseAltSigs=true
  • -Xoptimize (EVM option) ignore silently
  • -Xprof – enables flat profiling
  • -Xaprof – enables alloc profiling
  • -Xconcurrentio – UseLWPSynchronization=true, BackgroundCompilation=false, DeferThrSuspendLoopCount=1, UseTLAB=false, NewSizeThreadIncrease=16KB
  • -Xinternalversion – print internal version information
  • -Xprintflags (#ifndef PRODUCT) – which is apparently the JDK I have.
  • – enable JMX
  • -Xint – set mode to int
  • -Xmixed – set mode to mixed (same as default)
  • -Xcomp – turn of all flags that inhibit compilation.
  • -Xshare
    • :dump – DumpSharedSpaces=true
    • :on – UseSharedSpaces=true, RequireSharedSpaces=true
    • :off – UseSharedSpaces=false, RequireSharedSpaces=false
  • -Xverify:[all|remote|local] – set BytecodeVerificationLocal to appropriate values.
  • -Xdebug
  • -Xnoagent – refuse to load old style agent.dll
  • -Xboundthreads – solaris only. Bind user level threads to kernel threads
  • -Xloggc:<filename> – redirect gc output to a file. PrintGC=true, PrintGCTimeStamps=true
  • -Xcheck:jni – JNI Checking is enabled if allowed for the VM.
  • vfprintf, exit, abort – sets hooks for all of these.
  • -XX:+AggressiveHeap – optimal for long running, memory allocation intensive jobs. Large cpu & memory machines. Total memory of VM must be over 256MB
    • Initial heap size is at least 1/2 of total
    • Young generation is 3/8ths of total heap
    • Enable ParallelGC and adaptive generation sizing
    • Encourage steady state memory management
    • ScavangeBeforeFullGC=false — this improves mutator locality
  • -XX:+NeverTenure
  • -XX:+AlwaysTenure
  • -XX:+/-CMSPermGenSweepingEnabled – use CMSClassUnloadingEnabled in the future
  • -XX:+/-UseGCTimeLimit – use UseGCOverheadLimit in the future
  • Java 1.3 compatibility – do not use: -XX:MaxTLERatio, -XX:+/-ResizeTLE, -XX:+/-PrintTLE, -XX:TLEFragmentationRatio, -XX:TLESize, -XX:TLEThreadRatio, -XX:+/-UseTLE.
  • Solaris only: -XX:+/-UsePermISM
  • -XX:+DisplayVMOutputToStderr
  • -XX:+DisplayVMOutputToStdout
  • -XX:+ExtendedDTraceProbes – if DTrace is enabled
  • -XX:+FullGCALot – disables scavenge before parallel mark-compact.
  • -XX:CMSParPromoteBlocksToClaim= or -XX:ParCMSPromoteBlocksToClaim= or -XX:ParallelGCOldGenAllocBufferSize= – replaced by -XX:OldPLABSize in the future
  • -XX:ParallelGCToSpaceAllocBufferSize= – use -XX:YoungPLABSize in the future
  • -XX:CMSMarkStackSize= or -XX:G1MarkStackSize
  • -XX:CMSMarkStackSizeMax
  • -XX:ParallelMarkingThreads or -XX:ParallelCMSThreads – set concurrent GC threads
  • -XX:MaxDirectMemorySize=
  • -XX:+UseVMInterruptibleIO – will be removed in JDK9 and will cause initialization failure in JDK9 if used.
  • -XX:+ManagementServer – start JMX

EVM can be found here.

TLE was predecessor to TLAB (Thread Local Allocation Buffer).

More terms can be found here:


From → Java

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: