5

I am running a jvm (java 8) with parameters "-XX:MetaspaceSize=256M and -XX:MaxMetaspaceSize=256M". When I execute "jstat -gcmetacapacity <PID>", it outputs,

  MCMN       MCMX        MC       CCSMN      CCSMX       CCSC     YGC   FGC    FGCT     GCT   
       0.0  1157120.0   122880.0        0.0  1048576.0    14336.0   499     5    1.131   12.653

I would expect both MCMN and MCMX to be 256M.

This looks similar to bug http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8077987. But it has been closed with documentation fix for MC. I am hoping it is jstat bug and java configuration is correct. Is there another way to confirm this?

Java version

java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Muhammad Shahzad
  • 9,340
  • 21
  • 86
  • 130
nitzien
  • 1,117
  • 9
  • 23
  • So you are “hoping it is jstat bug and java configuration is correct”. *Why*? Do you experience any problems with your application? Apparently not, otherwise, you described your actual problem here. So why do you think that you have to mess with metaspace configuration options at all? – Holger Jun 15 '16 at 08:55
  • We had out of memory issue due to metaspace hitting roof. We increased metaspace and still hit out of memory. So, needed to check if metaspace configuration is set correctly. After posting this question, we figured out that out of memory was same as this. http://stackoverflow.com/questions/33255578/old-jaxb-and-jdk8-metaspace-outofmemory-issue. Out of memory issue is fixed now. – nitzien Jun 16 '16 at 04:55
  • To make it clear: *without* the `MaxMetaspaceSize` option, the meta space is *unlimited* and the meta space will be sized as needed. If you experience problems “due to metaspace hitting roof”, you are encountering a self-made problem due to creating the roof in the first place. So the question is, what kind of problem did you have *before* adding the `MaxMetaspaceSize` option? – Holger Jun 16 '16 at 09:30
  • Obviously, if MaxMetaspaceSize is not set, my application will keep consuming memory till whole of available memory is consumed. As I mentioned there was bug in third party library causing this. And that is reason we should use MaxMetaspaceSize. Anyway, I want to confirm if it is jstat bug and if there is another way to figure out if maxMetaSpaceSize is correctly set for jvm. – nitzien Jun 16 '16 at 12:54
  • 1
    Right, MaxMetaspaceSize exists not to protect the JVM, but to protect the rest of the system in case the JVM misbehaves for some reason. It limits the amount of native memory the JVM can steal away from the OS and other processes on the system, so it is an important safeguard, and not setting it is not smart, unless this JVM is the only important process on the entire server. – volkerk Dec 22 '20 at 20:18

1 Answers1

1

Yes, that bug was simply closed in error, since the -gcmetacapacity jstat command doesn't report anything useful at all if it doesn't respect/report the limits imposed upon the JVM via the -XX:MetaspaceSize and -XX:MaxMetaspaceSize parameters. The entire jstat command exists to report on the effective behavior of the specific JVM instance, not on some theoretic limits that might exist in your environment. The theoretic maximum capacity for the metaspace is completely irrelevant to everybody, as is the theoretic minimum capacity of 0.

volkerk
  • 134
  • 1
  • 7