JAVA(1) JDK Commands JAVA(1) (NAME) java - (SYNOPSIS) : java [options] mainclass [args ...] JAR: java [options] -jar jarfile [args ...] : java [options] -m module[/mainclass] [args ...] java [options] --module module[/mainclass] [args ...] : java [options] source-file [args ...] options : . Overview of Java Options . mainclass . classname (main) . -jar jarfile JAR . jarfile JAR Main-Class:classname public static void main(String[] args) . -jar JAR (class path) . JAR jar . -m --module module[/mainclass] mainclass module . mainclass . Standard Options for Java . source-file . (source-file mode) . Using Source-File Mode to Launch Single-File Source-Code Programs . args ... : mainclass source-file -jar jarfile -m --module module/mainclass . (DESCRIPTION) java . (JVM) main() . public static String . : public static void main(String[] args) java . Using Source- File Mode to Launch Single-File Source-Code Programs . : JDK_JAVA_OPTIONS java . Using the JDK_JAVA_OPTIONS Launcher Environment Variable . java (fully qualified name) . -jar JAR . Main-Class . JAR main() ..SS javaw : javaw java javaw . javaw . javaw . (USING SOURCE-FILE MODE TO LAUNCH SINGLE-FILE SOURCE-CODE PROGRAMS) java . java : o . . o --source version . .java --source . . --source (version) N . API . --source N API JDK N . : N . N . N Java SE (21) javac --source --release . .java --source java . --source "" Java . . . HelloWorld.java hello.World : java HelloWorld.java (named package) (unnamed package) . hello.World : javac -d HelloWorld.java java -cp hello.World : o . : --class-path --module-path --add-exports --add-modules --limit-modules --patch-module --upgrade-module-path . --enable-preview JEP 12 . o -processor -Werror . o (@-files) . VM @ . : o . o (source path) . o (Annotation processing) -proc:none . o --source --release . API . o . o (top-level) . o JLS 7.6 .java . o . : o . public static void main(String[]) . o (application class loader) . (application class path) . o --add-modules=ALL-DEFAULT . --add-module . o main . o . JEP 330: Launch Single- File Source-Code Programs [https://openjdk.org/jeps/330] ..SH " JDK_JAVA_OPTIONS (USING THE JDK_JAVA_OPTIONS LAUNCHER ENVIRONMENT VARIABLE)" JDK_JAVA_OPTIONS . JDK_JAVA_OPTIONS ( isspace()) . java . (encoding) java . JDK_JAVA_OPTIONS . (') (") . . . @ . @ (wildcard) . JDK_JAVA_OPTIONS ( -jar) java ( -h) . . JDK_JAVA_OPTIONS stderr . : $ export JDK_JAVA_OPTIONS='-g @file1 -Dprop=value @file2 -Dws.prop="white spaces"' $ java -Xint @file3 : java -g @file1 -Dprop=value @file2 -Dws.prop="white spaces" -Xint @file3 (OVERVIEW OF JAVA OPTIONS) java : o (Standard Options for Java): (JVM) . JRE (class path) (verbose) . o (Extra Options for Java): Java HotSpot . JVM . -X . . Java HotSpot . (Performance Tuning Examples) . JVM . -XX . o (Advanced Runtime Options for Java): Java HotSpot VM . o JIT (Advanced JIT Compiler Options for java): (JIT) Java HotSpot VM . o (Advanced Serviceability Options for Java): . o (Advanced Garbage Collection Options for Java): (GC) Java HotSpot . (Boolean) . . -XX (-XX:+OptionName) (-XX:-OptionName) . (:) (=) ( ). k K (KB) m M (MB) g G (GB) . 8g 8192m 8388608k 8589934592 . 0 1 . 0.25 . : o (Deprecated Java Options): -- . o (Obsolete Java Options): -- . o (Removed Java Options): -- ..SH " (STANDARD OPTIONS FOR JAVA)" JVM . : --name=value --name value . -agentlib:libname[=options] (native agent) . . -agentlib:foo JVM foo : o (POSIX-like): JVM libfoo.so LD_LIBRARY_PATH . o (macOS): JVM libfoo.dylib DYLD_LIBRARY_PATH . o (Windows): JVM foo.dll PATH . (JDWP) JVM : -agentlib:jdwp=transport=dt_socket,server=y,address=8000 -agentpath:pathname[=options] . -agentlib . --class-path classpath -classpath classpath -cp classpath JAR ZIP . (;) (:) . classpath CLASSPATH . classpath (.) . (*) .jar .JAR . . mydir a.jar b.JAR mydir/* A.jar:b.JAR JAR . .jar . (*) jar . CLASSPATH . (wildcard) Java VM . System.getenv("CLASSPATH"). --disable-@files @filename . @ . --enable-preview [https://docs.oracle.com/en/java/javase/12/language/index.html#JSLAN- GUID-5A82FE0E-0CA4-4F1F-B075-564874FE2823] . --finalization=value JVM (finalization) . "enabled" "disabled". "enabled" . "disabled" . --module-path modulepath... -p modulepath . . JAR (exploded-module). (;) (:) . --upgrade-module-path modulepath... . . JAR (exploded-module). (;) (:) . --add-modules module[,module...] . module ALL-DEFAULT ALL-SYSTEM ALL-MODULE-PATH . --list-modules . -d module_name --describe-module module_name . --dry-run (VM) (main) . --dry-run . --validate-modules . . -Dproperty=value . property . value . value ( -Dfoo="foo bar"). -disableassertions[:[packagename]...|:classname] -da[:[packagename]...|:classname] (assertions) . . -disableassertions (-da) . packagename ... . ... . classname . -disableassertions (-da) ( ) . : . . -disablesystemassertions . -enableassertions (-ea) . . MyClass com.wombat.fruitbat ( ) com.wombat.fruitbat.Brickbat : java -ea:com.wombat.fruitbat... -da:com.wombat.fruitbat.Brickbat MyClass -disablesystemassertions -dsa . -enableassertions[:[packagename]...|:classname] -ea[:[packagename]...|:classname] . . -enableassertions (-ea) . packagename ... . ... . classname . -enableassertions (-ea) (class loaders) ( ) . : . (assertions) . -enablesystemassertions . -disableassertions (-da) . . MyClass com.wombat.fruitbat ( ) com.wombat.fruitbat.Brickbat : java -ea:com.wombat.fruitbat... -da:com.wombat.fruitbat.Brickbat MyClass -enablesystemassertions -esa (assertions) . -help -h -? (error stream) . --help (output stream) . -javaagent:jarpath[=options] (agent) . java.lang.instrument . --show-version . -showversion . --show-module-resolution (module resolution) . -splash:imagepath (splash screen) imagepath . HiDPI . image.ext -splash . . splash.gif images : -splash:images/splash.gif SplashScreen API . -verbose:class . -verbose:gc (GC) . -verbose:jni (JNI) . -verbose:module . --version . -version . -X . --help-extra . @argfile @ java . .jar classpath java . @argfile . --disable-@files . . java : java @argfile @-argfile java Command-Line Argument Files . (EXTRA OPTIONS FOR JAVA) java Java HotSpot . -Xbatch . JVM (interpreter mode) . -Xbatch . -XX:-BackgroundCompilation . -Xbootclasspath/a:directories|zip|JAR-files JAR ZIP (bootstrap class path) . Windows (;) (:) . -Xcheck:jni (JNI) . JVM : o JVM . o JNIEnv . o : o jfieldID jmethodID . : o o o . o . : o NULL o o UTF-8 o JNI o ReleaseXXX GetXXX : o JNI JNI . o (Lname;) . o NULL . o JNI Get/ReleasePrimitiveArrayCritical Get/ReleaseStringCritical . -Xcomp JIT. . -Xdebug . . -Xdiag . -Xint . . (JIT) . -Xinternalversion JVM -version . -Xlog:option () (JVM). Enable Logging with the JVM Unified Logging Framework . -Xmixed (hot methods) . . -Xint . -Xmn size ( ) (nursery) . k K m M g G . . (GC) . (minor) . . G1 . 256 MB : -Xmn256m -Xmn262144k -Xmn268435456 -Xmn -XX:NewSize -XX:MaxNewSize . -Xms size ( ) . 1024 1 MB . k K m M g G . 6 MB : -Xms6291456 -Xms6144k -Xms6m (old generation) . -Xmn -XX:NewSize . -XX:InitialHeapSize . -Xms -XX:InitialHeapSize . -Xmx size ( ) . 1024 2 MB . k K m M g G . . -Xms -Xmx . 80 MB : -Xmx83886080 -Xmx81920k -Xmx80m -Xmx -XX:MaxHeapSize . -Xnoclassgc (GC) . GC . -Xnoclassgc . (out-of-memory) . -Xrs JVM . (shutdown hooks) ( ) JVM . o (Non-Windows): o JVM . JVM SIGHUP SIGINT SIGTERM . o JVM SIGINT SIGTERM JVM . -Xrs . -Xrs SIGINT SIGTERM SIGHUP SIGQUIT JVM . o (Windows): o JVM . JVM CTRL_C_EVENT CTRL_CLOSE_EVENT CTRL_LOGOFF_EVENT CTRL_SHUTDOWN_EVENT TRUE . o JVM (thread dumps) . JVM CTRL_BREAK_EVENT . o JVM ( ) CTRL_LOGOFF_EVENT . -Xrs . -Xrs JVM CTRL_C_EVENT CTRL_CLOSE_EVENT CTRL_LOGOFF_EVENT CTRL_SHUTDOWN_EVENT . -Xrs : o : SIGQUIT . o : Ctrl + Break . System.exit() JVM . -Xshare:mode (CDS) . mode :.TP auto (). on . : -Xshare:on . CDS ( VM JDK ) VM . . off . -XshowSettings . -XshowSettings:category . category : all . . locale locale . properties (system properties) . vm JVM . system : . -Xss size (thread stack size) ( ) . k K m M g G . (system page size) . . : o Linux/x64: 1024 KB o Linux/Aarch64: 2048 KB o macOS/x64: 1024 KB o macOS/Aarch64: 2048 KB o Windows: 1024 KB : -Xss1m -Xss1024k -Xss1048576 -XX:ThreadStackSize . --add-reads module=target-module(,target-module)* module target-module . target-module all unnamed . --add-exports module/package=target-module(,target-module)* module package target-module . target-module all unnamed . --add-opens module/package=target-module(,target-module)* module package target-module . --limit-modules module[,module...] . --patch-module module=file(;file)* JAR . --source version (source) (source-file mode) . MACOS (EXTRA OPTIONS FOR MACOS) macOS . -XstartOnFirstThread main() (AppKit) . -Xdock:name=application_name dock . -Xdock:icon=path_to_icon_file dock . JAVA (ADVANCED OPTIONS FOR JAVA) java . -XX:+UnlockDiagnosticVMOptions JVM . . . Oracle Support . . -XX:+UnlockExperimentalVMOptions JVM . ..SH " (ADVANCED RUNTIME OPTIONS FOR JAVA)" java Java HotSpot VM . -XX:ActiveProcessorCount=x CPU VM (thread pools) Garbage Collection ForkJoinPool . VM . (partitioning) CPU docker . UseContainerSupport . -XX:-UseContainerSupport . -XX:AllocateHeapAt=path (object heap) . HotSpot VM NV-DIMM . DRAM (atomic) DRAM . ( code heap metaspace ) DRAM . -DRAM . (memory- mapped) (page cache) . ( -Xmx -Xms) garbage collection . -XX:-CompactStrings (Compact Strings) . . ISO-8859-1 / Latin-1 -- . . : UTF-16 . Compact Strings UTF-16 . Compact Strings : o o Java SE 8 Java SE 9 Compact Strings Compact Strings . -XX:ErrorFile=filename . hs_err_pidpid.log pid . ( %p ): -XX:ErrorFile=./hs_err_pid%p.log o (Non-Windows): /var/log/java/java_error.log : -XX:ErrorFile=/var/log/java/java_error.log o (Windows): C:/log/java/java_error.log : -XX:ErrorFile=C:/log/java/java_error.log . ( ) : o (Non-Windows): /tmp . o (Windows): TMP TEMP . -XX:+ExtensiveErrorReports ErrorFile . - / . . . -XX:FlightRecorderOptions=parameter=value () -XX:FlightRecorderOptions:parameter=value JFR . . parameter=value JFR : globalbuffersize=size . memorysize . memorysize . maxchunksize=size ( ) . (MB) m M (GB) g G . 12 . 1 . memorysize=size globalbuffersize numglobalbuffers . (MB) m M (GB) g G . 10 . numglobalbuffers . . memorysize . old-object-queue-size=number-of-objects (old objects) . . preserve-repository={true|false} JVM . false . . repository=path ( ) . . retransform={true|false} JVMTI (retransform) . false (instrumentation) . . stackdepth=depth (stack trace). . . . threadbuffersize=size ( ) . . . -XX:LargePageSizeInBytes=size (large page size) JVM ( ) . size . k K m M g G . 0 JVM . Large Pages . (large pages) (GB) : -XX:LargePageSizeInBytes=1g -XX:MaxDirectMemorySize=size ( ) (direct-buffer) java.nio . k K m M g G . JVM NIO . NIO : -XX:MaxDirectMemorySize=1m -XX:MaxDirectMemorySize=1024k -XX:MaxDirectMemorySize=1048576 -XX:-MaxFDLimit (soft limit) (hard limit) . Windows . macOS . -XX:NativeMemoryTracking=mode (native memory) (JVM) . mode : off JVM . -XX:NativeMemoryTracking . summary JVM (heap) (thread) . detail JVM CallSite (committed) . -XX:TrimNativeHeapInterval=millis ( ) JVM (trim) . . 0 () . (thread) . Linux (glibc) . -XX:+NeverActAsServerClassMachine << >> ("Client VM emulation") C1 JIT CodeCache Serial GC . JVM ( -XX:MaxRAM=n) . "emulated-client" JVM . Windows true false . <> : -XX:{+|-}TieredCompilation -XX:CompilationMode=mode -XX:TieredStopAtLevel=n -XX:{+|-}EnableJVMCI -XX:{+|-}UseJVMCICompiler -XX:ObjectAlignmentInBytes=alignment (memory alignment) ( ) . . ( ) . (compressed pointers) . : 4GB * ObjectAlignmentInBytes : . . -XX:OnError=string . . o : -XX:OnError gcore core image gdb ( %p ): -XX:OnError="gcore %p;gdb -p %p" o : -XX:OnError userdump.exe crash dump ( %p ). userdump.exe PATH : -XX:OnError="userdump.exe %p" -XX:OnOutOfMemoryError=string OutOfMemoryError . . -XX:OnError . -XX:+PrintCommandLineFlags JVM . JVM . . -XX:+PreserveFramePointer RBP (-XX:-PreserveFramePointer) RBP frame pointer (-XX:+PreserveFramePointer . frame pointer (profiling) ( Linux perf) (stack trace) . -XX:+PrintNMTStatistics JVM ( -XX:NativeMemoryTracking) . . -XX:SharedArchiveFile=path (CDS) . (Application Class Data Sharing) . -XX:+VerifySharedSpaces JVM CDS CRC32 . CDS . CDS CDS . -XX:SharedArchiveConfigFile=shared_config_file ..TP -XX:SharedClassListFile=file_name (CDS) . (/) (.) . java.lang.Object hello.Main : java/lang/Object hello/Main . (class paths) (extension) (bootstrap) . Application Class Data Sharing . -XX:+ShowCodeDetailsInExceptionMessages NullPointerException . NullPointerException JVM (bytecode) null (null-detail message) . NullPointerException.getMessage() . . -XX:+ShowMessageBoxOnError JVM . JVM . . -XX:StartFlightRecording=parameter=value JFR Java . JFR.start . JFR parameter=value : delay=time Java . s m h d ( 10m ). 0 . disk={true|false} . . dumponexit={true|false} JVM (dump) . filename . (PID) hotspot-pid-47496-id-1-2018_01_25_19_10_41.jfr. . duration=time . s m h d ( 5h ). 0 . filename=path : o recording.jfr o /home/user/recordings/recording.jfr o c:\recordings\recording.jfr %p / %t PID JVM . name=identifier . maxage=time . disk true . s m h d ( 30s ). 0s . maxsize=size ( ) . disk true . maxchunksize -XX:FlightRecorderOptions . m M g G . 0 . path-to-gc-roots={true|false} (GC roots) . . GC roots . . settings profile (stack trace) . settings=path ( JFC) . default.jfc JAVA_HOME/lib/jfr . (overhead) . profile.jfc . . . .jfc : option=value . JAVA_HOME/bin/jfr . event-setting=value . : #=. '+' . .jfc . .jfc . (whitespace) 20ms. Javadoc jdk.jfr . -XX:ThreadStackSize=size (thread stack size) Java ( ) . k -XX:ThreadStackSize=1k Java 1024*1024 . . : o Linux/x64: 1024 KB o Linux/Aarch64: 2048 KB o macOS/x64: 1024 KB o macOS/Aarch64: 2048 KB o Windows: : -XX:ThreadStackSize=1k -XX:ThreadStackSize=1024 -Xss . -XX:-UseCompressedOops (compressed pointers) . . heap . . oops heap oops . JVM . heap . -XX:ObjectAlignmentInBytes . -XX:-UseContainerSupport : VM VM docker . . true . -XX:-UseContainerSupport . Unified Logging . -Xlog:os+container=trace . Unified Logging Enable Logging with the JVM Unified Logging Framework . -XX:+UseHugeTLBFS : -XX:+UseLargePages . . (large pages) JVM -XX:UseTransparentHugePages . Large Pages . -XX:+UseLargePages (large page memory) . . Large Pages . -XX:+UseTransparentHugePages : . . (transparent huge pages) . -XX:+AllowUserSignalHandlers : (signal handlers) . . -XX:VMOptionsFile=filename VM : java -XX:VMOptionsFile=/var/my_vm_options HelloWorld. -XX:UseBranchProtection=mode AArch64: (branch protection) . none VM . (native) . mode : none . . standard . pac-ret ROP . ( AArch64 8.3+) JIT (ADVANCED JIT COMPILER OPTIONS FOR JAVA) java (JIT) Java HotSpot VM . -XX:AllocateInstancePrefetchLines=lines (prefetch) . : -XX:AllocateInstancePrefetchLines=1 -XX:AllocatePrefetchDistance=size ( ) . . (thread) . . . k K m M g G . -1 . : -XX:AllocatePrefetchDistance=1024 -XX:AllocatePrefetchInstr=instruction . . . : -XX:AllocatePrefetchInstr=0 -XX:AllocatePrefetchLines=lines (cache lines) . (instance) . : -XX:AllocatePrefetchLines=5 -XX:AllocatePrefetchStepSize=size ( ) . k K m M g G . : -XX:AllocatePrefetchStepSize=16 -XX:AllocatePrefetchStyle=style . style : 0 . 1 . . 2 (TLAB) ..TP 3 (cache line) prefetch . -XX:+BackgroundCompilation . . -XX:-BackgroundCompilation ( -Xbatch ). -XX:CICompilerCount=threads . . : -XX:CICompilerCount=2 -XX:+UseDynamicNumberOfCompilerThreads -XX:CICompilerCount . . -XX:CompileCommand=command,method[,option] command () method () . indexOf() String : -XX:CompileCommand=exclude,java/lang/String.indexOf (/) . -XX:+PrintCompilation -XX:+LogCompilation : -XX:CompileCommand=exclude,java.lang.String::indexOf . . - . indexOf(String) String : -XX:CompileCommand="exclude,java/lang/String.indexOf,(Ljava/lang/String;)I" (*) . indexOf() : -XX:CompileCommand=exclude,*.indexOf . -XX:CompileCommand : -XX:CompileCommand="exclude java/lang/String indexOf" JIT -XX:CompileCommand .hotspot_compiler . -XX:CompileCommandFile . -XX:CompileCommand (\n) . : break JVM (breakpoint) . compileonly . -XX:CompileOnly . dontinline (inlining) . exclude . help -XX:CompileCommand . inline (inline) . log ( -XX:+LogCompilation) . . option JIT (option) . . BlockLayoutByFrequency append() StringBuffer : -XX:CompileCommand=option,java/lang/StringBuffer.append,BlockLayoutByFrequency . print . quiet . -XX:CompileCommand indexOf() String : CompilerOracle: exclude java/lang/String.indexOf -XX:CompileCommand=quiet -XX:CompileCommand . -XX:CompileCommandFile=filename JIT . .hotspot_compiler JIT . . toString() String : print java/lang/String toString JIT -XX:CompileCommand . -XX:CompilerDirectivesFile=file . Compiler Control [https://docs.oracle.com/en/java/javase/12/vm/compiler- control1.html#GUID-94AD8194-786A-4F19-BFFF-278F8E237F3A] . -XX:CompilerDirectivesFile -XX:UnlockDiagnosticVMOptions JVM . -XX:+CompilerDirectivesPrint . -XX:+CompilerDirectivesPrint -XX:UnlockDiagnosticVMOptions JVM . -XX:CompileOnly=methods ( ) . . ( ) . length() String size() List : -XX:CompileOnly=java/lang/String.length,java/util/List.size (/) . (cut and paste) -XX:+PrintCompilation -XX:+LogCompilation : -XX:CompileOnly=java.lang.String::length,java.util.List::size (wildcard) : -XX:CompileOnly=java/lang/String -XX:CompileOnly=java/lang -XX:CompileOnly=.length -XX:CompileThresholdScaling=scale . (tiered) (nontiered) . CompileThresholdScaling 0 +Inf ( ) . CompileThresholdScaling 1.0 1.0 . CompileThresholdScaling 0 . -XX:+DoEscapeAnalysis (escape analysis) . . -XX:-DoEscapeAnalysis . -XX:InitialCodeCacheSize=size (code cache) ( ) . k K m M g G . (platform) . . : -XX:InitialCodeCacheSize=32k -XX:+Inline (method inlining) . . -XX:-Inline . -XX:InlineSmallCode=size ( ) . C2 . k K m M g G . . : -XX:InlineSmallCode=1000 -XX:+LogCompilation hotspot.log . -XX:LogFile . . -XX:+LogCompilation -XX:UnlockDiagnosticVMOptions JVM . -XX:+PrintCompilation (verbose) . -XX:FreqInlineSize=size ( ) (hot method) . C2 . k K m M g G . . : -XX:FreqInlineSize=325 -XX:MaxInlineSize=size ( ) (cold method) . C2 . k K m M g G . : -XX:MaxInlineSize=35 -XX:C1MaxInlineSize=size ( ) . C1 . k K m M g G . : -XX:MaxInlineSize=35 -XX:MaxTrivialSize=size ( ) (trivial method) . C2 . k K m M g G . : -XX:MaxTrivialSize=6 -XX:C1MaxTrivialSize=size ( ) . C1 . k K m M g G . : -XX:MaxTrivialSize=6 -XX:MaxNodeLimit=nodes . . , : -XX:MaxNodeLimit=100000 -XX:NonNMethodCodeHeapSize=size (nonmethod code) . . . -XX:SegmentedCodeCache . -XX:NonProfiledCodeHeapSize=size (code segment) (nonprofiled) . -XX:SegmentedCodeCache . -XX:+OptimizeStringConcat (concatenation) String . . String -XX:-OptimizeStringConcat . -XX:+PrintAssembly (native) hsdis-.so .dll . Windows hsdis-amd64.dll . . . -XX:+PrintAssembly -XX:UnlockDiagnosticVMOptions JVM . -XX:ProfiledCodeHeapSize=size (profiled) . -XX:SegmentedCodeCache . -XX:+PrintCompilation (verbose) JVM . . . -XX:+LogCompilation (log) . -XX:+PrintInlining (inlining) . . . -XX:+PrintInlining -XX:+UnlockDiagnosticVMOptions JVM . -XX:ReservedCodeCacheSize=size (code cache) JIT ( ) . k K m M g G . (tiered compilation) -XX:-TieredCompilation . . -XX:InitialCodeCacheSize . -XX:RTMAbortRatio=abort_ratio (abort ratio) RTM (%) RTM . (deoptimized) . -XX:+UseRTMDeopt . . . -XX:RTMRetryCount=number_of_retries RTM . . -XX:UseRTMLocking . -XX:+SegmentedCodeCache (code cache) . -XX:+SegmentedCodeCache (non-method) (profiled method) (non-profiled method) . . (memory footprint) (code fragmentation) iTLB (instruction translation lookaside buffer) . (-XX:+TieredCompilation ) (-XX:ReservedCodeCacheSize) . -XX:StartAggressiveSweepingAt=percent . . -XX:-TieredCompilation (tiered compilation) . . -XX:UseSSE=version SSE . ( x86). -XX:UseAVX=version AVX . ( x86). -XX:+UseAES (intrinsics) AES . . -XX:+UseAES UseAESIntrinsics . -XX:+UnlockDiagnosticVMOptions . -XX:+UseAESIntrinsics AES . -XX:+UseAESIntrinsics -XX:+UseAES . AES -XX:-UseAES -XX:-UseAESIntrinsics . AES : -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UnlockDiagnosticVMOptions . -XX:+UseAESCTRIntrinsics -XX:+UseAESIntrinsics AES/CTR . -XX:+UseGHASHIntrinsics GHASH . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseChaCha20Intrinsics ChaCha20 . . ChaCha20 -XX:-UseChaCha20Intrinsics . -XX:+UnlockDiagnosticVMOptions . -XX:+UsePoly1305Intrinsics Poly1305 . . Poly1305 -XX:-UsePoly1305Intrinsics . -XX:+UnlockDiagnosticVMOptions . -XX:+UseBASE64Intrinsics BASE64 java.util.Base64 . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseAdler32Intrinsics (checksum) Adler32 java.util.zip.Adler32 . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseCRC32Intrinsics CRC32 java.util.zip.CRC32 . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseCRC32CIntrinsics CRC32C java.util.zip.CRC32C . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSHA SHA . UseSHA UseSHA1Intrinsics UseSHA256Intrinsics UseSHA512Intrinsics . UseSHA UseSHA*Intrinsics . sun.security.provider.Sun SHA . (intrinsics) -XX:+UnlockDiagnosticVMOptions . SHA -XX:-UseSHA . SHA . : -XX:-UseSHA256Intrinsics. -XX:+UseSHA1Intrinsics SHA-1 . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSHA256Intrinsics SHA-224 SHA-256 . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSHA512Intrinsics SHA-384 SHA-512 . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMathExactIntrinsics (intrinsification) java.lang.Math.*Exact() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMultiplyToLenIntrinsic BigInteger.multiplyToLen() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseSquareToLenIntrinsic BigInteger.squareToLen() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMulAddIntrinsic BigInteger.mulAdd() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMontgomeryMultiplyIntrinsic BigInteger.montgomeryMultiply() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseMontgomerySquareIntrinsic BigInteger.montgomerySquare() . . -XX:+UnlockDiagnosticVMOptions . -XX:+UseCMoveUnconditionally CMove ( ) . -XX:+UseCodeCacheFlushing . . -XX:-UseCodeCacheFlushing . -XX:+UseCondCardMark . . . -XX:+UseCountedLoopSafepoints (safepoints) . . -XX:LoopStripMiningIter=number_of_iterations strip mined . Strip mining . . . 1,000 . -XX:LoopStripMiningIterShortLoop=number_of_iterations loop strip mining . . -XX:LoopStripMiningIter . -XX:+UseFMA FMA FMA ( Intel ARM64) . FMA java.lang.Math.fma(a, b, c) ( a * b + c ) . -XX:+UseRTMDeopt RTM (abort ratio) . -XX:RTMAbortRatio . . . -XX:+UseRTMLocking . -XX:+UseRTMLocking (RTM) (inflated) (fallback handler) . . RTM x86 (TSX) . RTM TSX Intel x86 . XBEGIN XABORT XEND XTEST RTM . XBEGIN XEND . XEND (commit) . XABORT XTEST . (inflated) . RTM . RTM TSX . RTM (highly contended) ( ) . RTM (coarse-grain locking) . ( (fine-grained locking) .) RTM (false cache line sharing) . . . -XX:+UseSuperWord superword . Superword (vectorization) . . superword -XX:-UseSuperWord ..SH " (ADVANCED SERVICEABILITY OPTIONS FOR JAVA)" java . -XX:+DisableAttachMechanism (attach) JVM . jcmd jstack jmap jinfo . : jcmd jinfo jmap jstack JDK JDK JDK . -XX:+DTraceAllocProbes macOS: dtrace . -XX:+DTraceMethodProbes macOS: dtrace (method-entry method-exit) . -XX:+DTraceMonitorProbes macOS: dtrace . -XX:+HeapDumpOnOutOfMemoryError heap heap (HPROF) java.lang.OutOfMemoryError . heap -XX:HeapDumpPath . OutOfMemoryError heap . -XX:HeapDumpPath=path heap heap (HPROF) -XX:+HeapDumpOnOutOfMemoryError . java_pid.hprof . (%p ): -XX:HeapDumpPath=./java_pid%p.hprof o : heap /var/log/java/java_heapdump.hprof : -XX:HeapDumpPath=/var/log/java/java_heapdump.hprof o : heap C:/log/java/java_heapdump.log : -XX:HeapDumpPath=C:/log/java/java_heapdump.log -XX:LogFile=path . hotspot.log . o : /var/log/java/hotspot.log : -XX:LogFile=/var/log/java/hotspot.log o : C:/log/java/hotspot.log : -XX:LogFile=C:/log/java/hotspot.log -XX:+PrintClassHistogram () : o : Control+\ (SIGQUIT) o : Control+C (SIGTERM) . jmap -histo jcmd pid GC.class_histogram pid . -XX:+PrintConcurrentLocks java.util.concurrent : o : Control+\ (SIGQUIT) o : Control+C (SIGTERM) . jstack -l jcmd pid Thread.print -l pid . -XX:+PrintFlagsRanges . Validate Java Virtual Machine Flag Arguments . -XX:+PerfDataSaveToFile jstat . hsperfdata_pid pid . jstat : jstat -class file:///path/hsperfdata_pid jstat -gc file:///path/hsperfdata_pid -XX:+UsePerfData perfdata . JVM . hsperfdata_userid . perfdata -XX:-UsePerfData ..SH " (ADVANCED GARBAGE COLLECTION OPTIONS FOR JAVA)" java (GC) Java HotSpot VM . -XX:+AggressiveHeap . (RAM CPU) . . -XX:+AlwaysPreTouch (touch / ) . . -XX:ConcGCThreads=threads GC . threads / . CPU JVM . GC : -XX:ConcGCThreads=2 -XX:+DisableExplicitGC System.gc() . System.gc() . System.gc() JVM GC . -XX:+ExplicitGCInvokesConcurrent GC System.gc() . -XX:+UseG1GC . -XX:G1AdaptiveIHOPNumInitialSamples=number -XX:UseAdaptiveIHOP G1 -XX:InitiatingHeapOccupancyPercent . G1 -XX:InitiatingHeapOccupancyPercent . 3 . -XX:G1HeapRegionSize=size G1 (Garbage-First) . 1 MB 32 MB . . 16 MB : -XX:G1HeapRegionSize=16m -XX:G1HeapWastePercent=percent . Java HotSpot VM (mixed) . 5 . -XX:G1MaxNewSizePercent=percent (young generation) . 60 . . -XX:DefaultMaxNewGenPercent . -XX:G1MixedGCCountTarget=number G1MixedGCLIveThresholdPercent . 8 . . -XX:G1MixedGCLiveThresholdPercent=percent . 85 . . -XX:G1OldCSetRegionLiveThresholdPercent . -XX:G1NewSizePercent=percent . 5 . . -XX:DefaultMinNewGenPercent . -XX:G1OldCSetRegionThresholdPercent=percent . 10 . -XX:G1ReservePercent=percent ( ) (promotion failure) G1 . . 10% . 20% : -XX:G1ReservePercent=20 -XX:+G1UseAdaptiveIHOP . G1 -XX:G1AdaptiveIHOPNumInitialSamples -XX:InitiatingHeapOccupancyPercent . -XX:InitiatingHeapOccupancyPercent . . -XX:InitialHeapSize=size ( ) . 0 1024 1 MB . k K m M g G . . 6 MB : -XX:InitialHeapSize=6291456 -XX:InitialHeapSize=6144k -XX:InitialHeapSize=6m 0 . -XX:NewSize . -Xms . -Xms -XX:InitialHeapSize -Xms . -XX:InitialRAMPercentage=percent JVM -XX:MaxRAM . 1.5625 . : -XX:InitialRAMPercentage=5 -XX:InitialSurvivorRatio=ratio (survivor space) (throughput garbage collector) ( -XX:+UseParallelGC ). (Adaptive sizing) -XX:+UseParallelGC . ( -XX:-UseAdaptiveSizePolicy) -XX:SurvivorRatio . (S) (Y) (R) : S=Y/(R+2) . . . ( ) . : -XX:InitialSurvivorRatio=4 -XX:InitiatingHeapOccupancyPercent=percent ( ) G1 . . GC G1 . -XX:G1UseAdaptiveIHOP -XX:G1AdaptiveIHOPNumInitialSamples . : -XX:InitiatingHeapOccupancyPercent=75 -XX:MaxGCPauseMillis=time GC ( ) . (soft goal) JVM . . G1 . . : -XX:MaxGCPauseMillis=500 -XX:MaxHeapSize=size ( ) . . k K m M g G . . -XX:InitialHeapSize -XX:MaxHeapSize . : -XX:MaxHeapSize=83886080 -XX:MaxHeapSize=81920k -XX:MaxHeapSize=80m -XX:MaxHeapSize -Xmx . -XX:MaxHeapFreeRatio=percent ( ) GC . . . MaxHeapFreeRatio ( ) MinHeapFreeRatio ( ) -XX:MaxHeapFreeRatio -XX:MinHeapFreeRatio . MaxHeapFreeRatio MinHeapFreeRatio . . -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:-ShrinkHeapInSteps . (embedded) Performance Tuning Examples . -XX:MaxMetaspaceSize=size (native memory) (class metadata) . . . : -XX:MaxMetaspaceSize=256m -XX:MaxNewSize=size ( ) (nursery) . . -XX:MaxRAM=size JVM . JVM . JVM ( container) . compressed oops compressed oops . compressed oops -XX:UseCompressedOops . : -XX:MaxRAM=2G -XX:MaxRAMPercentage=percent JVM -XX:MaxRAM . . compressed oops compressed oops . compressed oops -XX:UseCompressedOops . : -XX:MaxRAMPercentage=75 -XX:MinRAMPercentage=percent JVM (ergonomics heuristics) -XX:MaxRAM . . . : -XX:MinRAMPercentage=75 -XX:MaxTenuringThreshold=threshold (tenuring threshold) GC . . (parallel / throughput collector) . : -XX:MaxTenuringThreshold=10 -XX:MetaspaceSize=size (GC) . . (platform) . -XX:MinHeapFreeRatio=percent ( ) GC . . . MaxHeapFreeRatio ( ) MinHeapFreeRatio ( ) -XX:MaxHeapFreeRatio -XX:MinHeapFreeRatio . MaxHeapFreeRatio MinHeapFreeRatio . . -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:-ShrinkHeapInSteps . (dynamic footprint) (embedded) Performance Tuning Examples . -XX:MinHeapSize=size ( ) . . k K m M g G . . : -XX:MinHeapSize=6291456 -XX:MinHeapSize=6144k -XX:MinHeapSize=6m . -XX:NewRatio=ratio (young generation) (old generation) . . : -XX:NewRatio=1 -XX:NewSize=size ( ) (nursery) . k K m M g G . . GC . GC (minor GC) . GC (full GC) . . : -XX:NewSize=256m -XX:NewSize=262144k -XX:NewSize=268435456 -XX:NewSize -Xmn . -XX:ParallelGCThreads=threads (stop-the- world STW) . JVM . G1 GC : -XX:ParallelGCThreads=2 -XX:+ParallelRefProcEnabled (parallel reference processing) . . -XX:+PrintAdaptiveSizePolicy . . -XX:+ScavengeBeforeFullGC GC full GC . . full GC . GC full GC -XX:-ScavengeBeforeFullGC . -XX:SoftRefLRUPolicyMSPerMB=time ( ) soft ( ) . . -XX:SoftRefLRUPolicyMSPerMB ( Java HotSpot Client VM) ( Java HotSpot Server VM) . Client VM soft Server VM soft . -Xmx soft . : -XX:SoftRefLRUPolicyMSPerMB=2500 -XX:-ShrinkHeapInSteps -XX:MaxHeapFreeRatio . . . . . MaxHeapFreeRatio (embedded) Performance Tuning Examples . -XX:StringDeduplicationAgeThreshold=threshold String (deduplication) . (GC) . (tenuring) . : String deduplication . 3 . -XX:+UseStringDeduplication . -XX:SurvivorRatio=ratio eden survivor . 8 . eden/survivor 4 : -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=percent survivor ( 0 100) . 50% . survivor 30% : -XX:TargetSurvivorRatio=30 -XX:TLABSize=size ( ) (TLAB) . k K m M g G . 0 JVM . TLAB 512 : -XX:TLABSize=512k -XX:+UseAdaptiveSizePolicy . . -XX:-UseAdaptiveSizePolicy . -XX:SurvivorRatio . -XX:+UseG1GC Garbage-First (G1) . . GC . G1 ( 6 ) GC ( 0.5 ) . G1 . -XX:+UseGCOverheadLimit JVM GC OutOfMemoryError . 98% 2% OutOfMemoryError . . -XX:-UseGCOverheadLimit . -XX:+UseNUMA (NUMA) . NUMA . (-XX:+UseParallelGC) . -XX:+UseParallelGC (parallel scavenge collector ) . . -XX:+UseSerialGC (serial garbage collector) . . . -XX:+UseSHM : JVM (large pages) . Large Pages . -XX:+UseStringDeduplication (string deduplication) . . G1 . String String . String String . -XX:+UseTLAB (TLAB) . . TLAB -XX:-UseTLAB . -XX:+UseZGC Z ( ZGC) . . . 8MB 16TB . -XX:ZAllocationSpikeTolerance=factor ZGC . 2.0 . . 3.0 . -XX:ZCollectionInterval=seconds ( ) GC ZGC . 0 () . -XX:ZFragmentationLimit=percent ( ) ZGC . 25 . . -XX:+ZProactive GC ZGC . . ZGC . (idle) . -XX:+ZUncommit (uncommit) ZGC . . JVM . -XX:ZUncommitDelay=seconds ( ) (uncommit) . 300 (5 ) . (commit) . ..SH " (DEPRECATED JAVA OPTIONS)" java JDK . . -Xfuture (class-file) . . . -Xloggc:filename GC . java -Xloggc -verbose:gc . -Xloggc:filename -Xlog:gc:filename . Enable Logging with the JVM Unified Logging Framework . : -Xlog:gc:garbage-collection.log -XX:+FlightRecorder Java Flight Recorder (JFR) . JDK 8u40 JFR . -XX:InitialRAMFraction=ratio JVM (ergonomics heuristics) -XX:MaxRAM . 64 . -XX:InitialRAMPercentage . -XX:MaxRAMFraction=ratio JVM -XX:MaxRAM . 4 . compressed oops compressed oops . compressed oops -XX:UseCompressedOops . -XX:MaxRAMPercentage . -XX:MinRAMFraction=ratio JVM -XX:MaxRAM . . 2 . -XX:MinRAMPercentage . (OBSOLETE JAVA OPTIONS) java . --illegal-access=parameter relaxed strong encapsulation JEP 261 [https://openjdk.org/jeps/261#Relaxed-strong-encapsulation] . JDK 16 JEP 396 [https://openjdk.org/jeps/396] JDK 17 JEP 403 [https://openjdk.org/jeps/403] . (REMOVED JAVA OPTIONS) java JDK 21 : Unrecognized VM option option-name -XX:+ExtendedDTraceProbes macOS: dtrace . dtrace . : -XX:+DTraceMethodProbes -XX:+DTraceAllocProbes -XX:+DTraceMonitorProbes. Removed Java Options : o java 20 [https://docs.oracle.com/en/java/javase/20/docs/specs/man/java.html] o java 19 [https://docs.oracle.com/en/java/javase/19/docs/specs/man/java.html] o java 18 [https://docs.oracle.com/en/java/javase/18/docs/specs/man/java.html] o java 17 [https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html] o java 16 [https://docs.oracle.com/en/java/javase/16/docs/specs/man/java.html] o java 15 [https://docs.oracle.com/en/java/javase/15/docs/specs/man/java.html] o java 14 [https://docs.oracle.com/en/java/javase/14/docs/specs/man/java.html] o java 13 [https://docs.oracle.com/en/java/javase/13/docs/specs/man/java.html] o Java Platform, Standard Edition 12 [https://docs.oracle.com/en/java/javase/12/tools/java.html#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE] o Java Platform, Standard Edition 11 [https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-741FC470-AA3E-494A-8D2B-1B1FE4A990D1] o Java Platform, Standard Edition 10 [https://docs.oracle.com/javase/10/tools/java.htm#JSWOR624] o Java Platform, Standard Edition 9 [https://docs.oracle.com/javase/9/tools/java.htm#JSWOR624] o Java Platform, Standard Edition 8 Oracle JDK Windows [https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html#BGBCIEFC] o Java Platform, Standard Edition 8 Oracle JDK Solaris Linux macOS [https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html#BGBCIEFC].SH " (JAVA COMMAND-LINE ARGUMENT FILES)" @ java java . java . (@) java . java (@) . java --disable-@files . --disable-@files @ . java : o ASCII ASCII UTF-8. o MAXINT () . o (wildcards) . o (white space) (new line) . o \t \n \r \f . c:\Program Files "c:\\Program Files" c:\Program" "Files . o ('"') . o \n \r \t \f . ASCII . o (double quotation) . o . o # () . # . o @ @ ( @ ). o (\) . . (\) . o (\) (escape ). o (end-of-file) . o \ . o (*) ( *.java). o (@) . (Example of Open or Partial Quotes in an Argument File) -cp "lib/ cool/ app/ jars : -cp lib/cool/app/jars (Example of a Backslash Character Escaped with Another Backslash Character in an Argument File) : -cp c:\Program Files (x86)\Java\jre\lib\ext;c:\Program Files\Java\jre9\lib\ext : -cp "c:\\Program Files (x86)\\Java\\jre\\lib\\ext;c:\\Program Files\\Java\\jre9\\lib\\ext" -cp "/lib/cool app/jars:\ /lib/another app/jars" : -cp /lib/cool app/jars:/lib/another app/jars -cp "/lib/cool\ \app/jars" : -cp /lib/cool app/jars myargumentfile java : java @myargumentfile . path1/options path2/options . : java @path1/options @path2/classes CODE HEAP (CODE HEAP STATE ANALYTICS) (Overview) code heap JVM : o JIT o code heap o (method sweeper) code heap code heap . . code heap . . << >> (on request) . (Syntax) : jcmd pid Compiler.CodeHeap_Analytics [function] [granularity] code heap : -Xlog:codecache=Trace code heap <> VM : -Xlog:codecache=Debug code heap (granularity) CodeHeap State Analytics (OpenJDK) [https://bugs.openjdk.org/secure/attachment/75649/JVM_CodeHeap_StateAnalytics_V2.pdf] . JVM (ENABLE LOGGING WITH THE JVM UNIFIED LOGGING FRAMEWORK) (JVM) -Xlog . (SYNOPSIS) -Xlog[:[what][:[output][:[decorators][:output-options[,...]]]]] -Xlog:directive what (tags) (levels) tag1[+tag2...][*][=level][,...] . (*) . -Xlog Tags and Levels . output . output stdout . -Xlog Output . decorators (decorators) . decorators uptime level tags . Decorations . output-options -Xlog . directive : help disable async.SS (Description) (JVM) JVM . GC JVM . GC Xlog Convert GC Logging Flags to Xlog . (runtime) JVM . Xlog Convert Runtime Logging Flags to Xlog . -Xlog : -Xlog JVM info . -Xlog:help -Xlog (decorators) . -Xlog:disable . -Xlog[:option] . -Xlog . option : [tag- selection][:[output][:[decorators][:output-options]]] tag-selection all info . tag[+...] all all (meta tag) . * (wildcard) . . . output-options : filecount=file-count filesize= K M G foldmultilines= foldmultilines true '\' 'n' . . UTF-8 . Shift JIS BIG5 . (Default Configuration) -Xlog . warning error . : -Xlog:all=warning:stdout:uptime,level,tags (Controlling Logging at Runtime) ( jcmd) . VM.log . MBean JMX . -Xlog (-Xlog Tags and Levels) . JVM ( gc jit os). GC Xlog Convert GC Logging Flags to Xlog . Xlog Convert Runtime Logging Flags to Xlog . : o off o trace o debug o info o warning o error : . -Xlog:help . all ..SS -Xlog -Xlog : o stdout --- stdout o stderr --- stderr o file=filename --- () . file=filename %p / %t PID JVM . (rotation) . filesize=10M, filecount=5 . . . filecount=0 . . -Xlog (synchronous) . (asynchronous) : -Xlog:async . (thread) (flush) . . (non-blocking) . -XX:AsyncLogBufferSize=N . . . (Decorations) () . . . . . : [6.567s][info][gc,old] Old collection complete decorators uptime level tags . none . time (t) utctime (utc) uptime (u) timemillis (tm) uptimemillis (um) timenanos (tn) uptimenanos (un) hostname (hn) pid (p) tid (ti) level (l) tags (tg) none . ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- time t ISO-8601. utctime utc (UTC). uptime u JVM . 6.567s. timemillis tm System.currentTimeMillis(). uptimemillis um JVM. timenanos tn System.nanoTime(). uptimenanos un JVM. hostname hn (hostname). pid p . tid ti . level l . tags tg . GC Xlog GC Xlog tab( ); lw(22.4n) lw(16.5n) lw(31.2n). Garbage Collection (GC) Xlog T} ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- G1PrintHeapRegions -Xlog:gc+region=trace T} GCLogFileSize . T} NumberOfGCLogFiles . T} PrintAdaptiveSizePolicy -Xlog:gc+ergo*=level level debug PrintAdaptiveSizePolicy level trace . T} PrintGC -Xlog:gc T} PrintGCApplicationConcurrentTime -Xlog:safepoint PrintGCApplicationConcurrentTime PrintGCApplicationStoppedTime . T} PrintGCApplicationStoppedTime -Xlog:safepoint PrintGCApplicationConcurrentTime PrintGCApplicationStoppedTime . T} PrintGCCause GC . T} PrintGCDateStamps . T} PrintGCDetails -Xlog:gc* T} PrintGCID GC . T} PrintGCTaskTimeStamps -Xlog:gc+task*=debug T} PrintGCTimeStamps . T} PrintHeapAtGC -Xlog:gc+heap=trace T} PrintReferenceGC -Xlog:gc+ref*=debug PrintReferenceGC PrintGCDetails . T} PrintStringDeduplicationStatistics `-Xlog:gc+stringdedup*=debug ` T} PrintTenuringDistribution -Xlog:gc+age*=level level debug PrintTenuringDistribution level trace . T} UseGCLogFileRotation PrintTenuringDistribution . T} . (unified logging) . Xlog tab( ); lw(15.0n) lw(20.2n) lw(34.7n). Xlog T} ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- TraceExceptions -Xlog:exceptions=info T} TraceClassLoading -Xlog:class+load=level level=info level=debug . Unified Logging -verbose:class -Xlog:class+load=info,class+unload=info . T} TraceClassLoadingPreorder -Xlog:class+preorder=debug T} TraceClassUnloading -Xlog:class+unload=level level=info level=trace . Unified Logging -verbose:class -Xlog:class+load=info,class+unload=info . T} VerboseVerification -Xlog:verification=info T} TraceClassPaths -Xlog:class+path=info T} TraceClassResolution -Xlog:class+resolve=debug T} TraceClassInitialization -Xlog:class+init=info T} TraceLoaderConstraints -Xlog:class+loader+constraints=info T} TraceClassLoaderData -Xlog:class+loader+data=level level=debug level=trace . T} TraceSafepointCleanupTime -Xlog:safepoint+cleanup=info T} TraceSafepoint -Xlog:safepoint=debug T} TraceMonitorInflation -Xlog:monitorinflation=debug T} TraceRedefineClasses -Xlog:redefine+class*=level level=info debug trace . T} -Xlog . -Xlog info uptime levels tags stdout . : -Xlog:all=info:stdout:uptime,levels,tags -Xlog:gc gc info stdout . warning . -Xlog:gc,safepoint gc safepoint info stdout . gc safepoint . -Xlog:gc+ref=debug gc ref debug stdout . . -Xlog:gc=debug:file=gc.txt:none gc debug gc.txt . warning . -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024 gc trace gctrace.txt uptimemillis pid . warning . -Xlog:gc::uptime,tid gc 'info' stdout uptime tid . warning . -Xlog:gc*=info,safepoint*=off gc info safepoint . gc safepoint . -Xlog:disable -Xlog:safepoint=trace:safepointtrace.txt safepoint trace safepointtrace.txt . -Xlog:disable . -Xlog -Xlog . -Xlog:gc+class*=debug gc class debug stdout . warning . -Xlog:gc+meta*=trace,class*=off:file=gcmetatrace.txt gc meta trace metatrace.txt class . gc meta class class* off . warning class . -Xlog:gc+meta=trace gc meta trace stdout . warning . -Xlog:gc+class+heap*=debug,meta*=warning,threads*=off gc class heap trace stdout meta . warning threads . " (VALIDATE JAVA VIRTUAL MACHINE FLAG ARGUMENTS)" (JVM) . API ( java.lang.management) (JVM) . Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide . JVM ( jcmd) . JVM . JVM : java -XX:AllocatePrefetchStyle=5 -version intx AllocatePrefetchStyle=5 is outside the allowed range [ 0 ... 3 ] Improperly specified VM option 'AllocatePrefetchStyle=5' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. -XX:+PrintFlagsRanges . . . : intx ThreadStackSize [ 0 ... 9007199254740987 ] {pd product} . : size_t NewSize [ ... ] {product} . ..SH " (LARGE PAGES)" (large pages) (huge pages) ( ). (Translation-Lookaside Buffers TLB) . (TLB) . TLB . TLB ( TLB miss) . TLB . TLB . . () (paging) . (fragmentation) . JVM . . " (Large Pages Support for Linux)" 2.6 . : # cat /proc/meminfo | grep Huge HugePages_Total: 0 HugePages_Free: 0 ... Hugepagesize: 2048 kB "Huge" . . Hugepagesize . . : # ls /sys/kernel/mm/hugepages/ hugepages-1048576kB hugepages-2048kB JVM . ( -XX:+UseTransparentHugePages) . root : # echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages nr_hugepages . -XX:+UseSHM SHMMAX . root : # echo 8589934592 > /proc/sys/kernel/shmmax . : /proc /sys ( rc.local sysctl.conf) . Java heap : o 2 (Code cache) o 2 (Marking bitmaps) nr_hugepages Java heap JVM heap (code cache) . " (Large Pages Support for Windows)" (administrator) : "1." 3 Control Panel Administrative Tools Local Security Policy . "2." 3 Local Policies User Rights Assignment . "3." 3 Lock pages in memory / . "4." 3 (Reboot) . (administrator) ..SH " (APPLICATION CLASS DATA SHARING)" << >> (AppCDS) . ( JAR) AppCDS . AppCDS . CDS JAR JDK . . . API . " CDS" JDK -Xshare:off JVM CDS JAVA_HOME/lib/server/classes.jsa ( JAVA_HOME\bin\server\classes.jsa) . . CDS -XX:SharedArchiveFile : -XX:SharedArchiveFile=: o 2 CDS . o 2 . o 2 (:) ; . ( "static" () "dynamic" () . "static" "dynamic" ). JVM . : -XX:SharedArchiveFile= . : -XX:SharedArchiveFile= " CDS" CDS : o 2 -Xshare:dump o 2 -XX:ArchiveClassesAtExit o 2 jcmd VM.cds << >> ("trial run") . " CDS -Xshare:dump" CDS test.Hello . "1." 3 test.Hello . hello.classlist : 4 java -Xshare:off -XX:DumpLoadedClassList=hello.classlist -cp hello.jar test.Hello -cp JAR . "2." 3 hello.jsa hello.classlist : 4 java -Xshare:dump -XX:SharedArchiveFile=hello.jsa -XX:SharedClassListFile=hello.classlist -cp hello.jar "3." 3 test.Hello hello.jsa : 4 java -XX:SharedArchiveFile=hello.jsa -cp hello.jar test.Hello "4." 3 test.Hello hello.jsa : 4 java -XX:SharedArchiveFile=hello.jsa -cp hello.jar -Xlog:class+load test.Hello : [info][class,load] test.Hello source: shared objects file CDS : o 2 . o 2 . CDS test.Hello CDS . "1." 3 CDS hello.jsa hello.jar test.Hello : 4 java -XX:ArchiveClassesAtExit=hello.jsa -cp hello.jar Hello "2." 3 test.Hello hello.jsa: 4 java -XX:SharedArchiveFile=hello.jsa -cp hello.jar test.Hello "3." 3 test.Hello hello.jsa . CDS CDS . : java -XX:SharedArchiveFile=base.jsa -XX:ArchiveClassesAtExit=hello.jsa -cp hello.jar Hello CDS: java -XX:SharedArchiveFile=base.jsa:hello.jsa -cp hello.jar Hello ( Windows : ; ) : java -XX:SharedArchiveFile=hello.jsa -cp hello.jar Hello CDS jcmd CDS . (class path) . jcmd VM.cds CDS JVM . : jcmd VM.cds static_dump my_static_archive.jsa : jcmd VM.cds dynamic_dump my_dynamic_archive.jsa : env JAVA_TOOL_OPTIONS=-XX:SharedArchiveFile=my_static_archive.jsa bash app_start.sh : jcmd VM.cds dynamic_dump JVM -XX:+RecordDynamicDumpInfo : env JAVA_TOOL_OPTIONS=-XX:+RecordDynamicDumpInfo bash app_start.sh CDS -XX:+AutoCreateSharedArchive -XX:+AutoCreateSharedArchive / CDS . CDS -XX:+AutoCreateSharedArchive . CDS . java -XX:+AutoCreateSharedArchive -XX:SharedArchiveFile=hello.jsa -cp hello.jar Hello JDK VM . VM . ( JDK 19) JDK . JVM . JDK JDK 19 : . CDS JDK . JDK -XX:+AutoCreateSharedArchive JDK . JDK ..SS Class Path Module Path o 2 (-classpath -Xbootclasspath/a) (--module-path) . o 2 --module-path JAR . (Exploded modules) . o 2 ( ). ( .) o 2 JAR CDS . o 2 VM --upgrade-module-path --patch-module --limit-modules CDS . JVM CDS . CDS JVM . " (PERFORMANCE TUNING EXAMPLES)" . : java -server -XX:+UseParallelGC -XX:+UseLargePages -Xmn10g -Xms26g -Xmx26g : java -XX:+UseG1GC -XX:MaxGCPauseMillis=100 : -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 : . . " (EXIT STATUS)" JVM . System.exit(exitValue) . : o 2 0: o 2 >0: JDK 21 2023 JAVA(1)