neil lee
neil lee

Reputation: 81

java -XX:-UseAdaptiveSizePolicy is not effective

I want to modify the maximum heap size through jinfo.

jinfo -flag MaxHeapSize=3122032640 <pid>

Since AdaptiveSizePolicy is enabled by default, modifying flags directly will result in an exception. So I disabled AdaptiveSizePolicy when the process started.

java -XX:-UseAdaptiveSizePolicy Sleep.java

I can also get the right result through jinfo

jinfo -flag UseAdaptiveSizePolicy 18220

-XX:-UseAdaptiveSizePolicy

But when I modify the maximum heap memory through jinfo again, exceptions will still occur.

jinfo -flag MaxHeapSize=3122032640 18220

Exception in thread "main" com.sun.tools.attach.AttachOperationFailedException: flag 'MaxHeapSize' cannot be changed
    at jdk.attach/sun.tools.attach.VirtualMachineImpl.execute(VirtualMachineImpl.java:224)
    at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:309)
    at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:282)
    at jdk.jcmd/sun.tools.jinfo.JInfo.flag(JInfo.java:146)
    at jdk.jcmd/sun.tools.jinfo.JInfo.main(JInfo.java:127)

It seems that -XX:-UseAdaptiveSizePolicy is not effective.

Does anyone know the reason?

I know the -Xmx flag to set the maximum heap size.

JDK: openjdk 13.0.1

OS: Ubuntu 18.04

VM flags:
-XX:CICompilerCount=3 -XX:ConcGCThreads=1 -XX:G1ConcRefinementThreads=4 -XX:G1HeapRegionSize=1048576 -XX:GCDrainStackTargetSize=64 -XX:InitialHeapSize=134217728 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=536870912 -XX:MaxNewSize=321912832 -XX:MinHeapDeltaBytes=1048576 -XX:MinHeapSize=134217728 -XX:NonNMethodCodeHeapSize=5830732 -XX:NonProfiledCodeHeapSize=122913754 -XX:ProfiledCodeHeapSize=122913754 -XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache -XX:SoftMaxHeapSize=536870912 -XX:-UseAdaptiveSizePolicy -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:+UseG1GC

Upvotes: 1

Views: 1667

Answers (1)

apangin
apangin

Reputation: 98284

I want to modify the maximum heap size through jinfo.

It is not possible. MaxHeapSize is not manageable flag, it cannot be changed in runtime.

-XX:UseAdaptiveSizePolicy flag is completely different thing. If configures whether GC may resize heap generations basing on the GC statistics, in order to achieve pause/throughput/footprint goals.

Upvotes: 2

Related Questions