There are a lot of articles and diagrams on this topic on the Internet, however, in my opinion, none of them allows you to form a general idea of ββthe memory use in the Java process. And without a general understanding, it is difficult to find solutions to specific memory problems in complex systems. As a result, I decided to post my diagrams.
Simplified diagram of Java memory usage of a process:
Detailed diagram of the Java memory usage of a process by some parameters:
JVM Copy Paste
-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=*:8000
JProfiler
VisualVM
JConsole
Java Flight Recorder
async-profiler
JDK Mission Control
jstack
jmap
These diagrams are not intended to provide complete knowledge, but they can be a starting point in exploring the topic deeper, filling knowledge gaps, tuning the JVM and finding the problem in the current system.