4

From Java 8 update 191 or later, or Java 10, 11,12, 13 etc. We have option called XX:+UseContainerSupport that is activated by default, so JVM can read limits for RAM And CPU inside container. With setting -XX:MaxRAMPercentage=90.0 I can tell JVM how much % of available RAM I want give to HEAP, but what about other JVM resources? like GC, CodeCache, ClassLoading, Metaspace, DirectBuffers and so on?

Does JVM also adapt its sizes (to left space after allocating heap) to not get over available RAM? Or do I still have to calculate it by myself in each case like following:

-XX:MetaspaceSize=64m -XX:ReservedCodeCacheSize=32m -XX:CompressedClassSpaceSize=16m -Xss256k 

For example if create a container with 1G RAM and run in it JVM with -XX:MaxRAMPercentage=90.0, so HEAP will take 900m, and there is will be only 100m for other JVM stuff, does this 100m will be intellectually distributed between all required resources, like setting XX:MaxMetaspaceSize (which is unlimited by default) ?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
psyskeptic
  • 286
  • 2
  • 4
  • 17

1 Answers1

9

The answer to the linked question also refers to my presentation, where I explain that so called "container support" in JDK affects nothing but

  • The default heap size
  • The number of available CPUs

So, the answer is NO: JVM does not resize other memory areas and does not attempt to satisfy container limits in any other way. You need to control them manually.

apangin
  • 92,924
  • 10
  • 193
  • 247