Reputation: 5333
from jmap result, we can see, free heap size(up to 90%) exceed MaxHeapFreeRatio(40%), but jvm still not shrink.
this is jvm info: java.vm.name = OpenJDK 64-Bit Server VM java.vm.version = 25.352-b1 java.runtime.version = 1.8.0_352-b1
VM Flags: Non-default VM flags: -XX:CICompilerCount=2 -XX:CompressedClassSpaceSize=1065353216 -XX:ConcGCThreads=1 -XX:G1HeapRegionSize=1048576 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=null -XX:InitialHeapSize=2577399808 -XX:InitialRAMPercentage=null -XX:MarkStackSize=4194304 -XX:MaxHeapFreeRatio=40 -XX:MaxHeapSize=6014631936 -XX:MaxMetaspaceSize=1073741824 -XX:MaxNewSize=3608150016 -XX:MaxRAMPercentage=null -XX:MetaspaceSize=536870912 -XX:MinHeapDeltaBytes=1048576 -XX:MinHeapFreeRatio=20 -XX:MinRAMPercentage=null -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:SurvivorRatio=6 -XX:+UseAdaptiveSizePolicy -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseContainerSupport -XX:+UseG1GC -XX:+UseUTF8UTF16Intrinsics
Command line: -Duser.timezone=GMT+8 -Dfile.encoding=utf-8 -XX:+UseContainerSupport -XX:InitialRAMPercentage=30.0 -XX:MinRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0 -XX:+UseAdaptiveSizePolicy -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=20 -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/logs/my-heap-dump.hprof -XX:SurvivorRatio=6 -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=1024m -Xloggc:/logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Djava.security.egd=file:/dev/./urandom
-XX:+UseAdaptiveSizePolicy -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=20
with these arguments, I think jvm should shrink dynamicly according to heap idea memory.
Upvotes: 0
Views: 149
Reputation: 43052
MaxHeapFreeRatio
is not honored immediately to avoid rapid allocation and deallocation of the heap in bursty workloads, you can add ShrinkHeapInSteps
to apply the limit more aggressively.
If that doesn't work you should look at the adaptive sizing policy decisions in the gc logs.
Upvotes: 0