2

Our installer updates our application from using java7 to java8. In doing so, we'd like to update their Tomcat7 configuration to limit the Metaspace at the same level as their PermGen space (which they might have customized). So if they had...

-XX:MaxPermSize=256m

we'd like to set...

-XX:MaxMetaspaceSize=256m

The trick is, the installer must do this via a batch file. (Perhaps querying Tomcat with some command that would spit out the present value to a file, and then read that value in, and then fire off another command to set the value.)

If I can get the present MaxPermSize, I know that last piece of the puzzle:

"%TOMCAT7_EXE%" %SERVICE_NAME% --JvmOptions "-XX:MaxMetaspaceSize=%MAX_SIZE%"

(It might also be nice to remove the no longer applicable MaxPermSize, but that would be just for extra-credit.)

the8472
  • 40,999
  • 5
  • 70
  • 122
LimaNightHawk
  • 6,613
  • 3
  • 41
  • 60
  • 1
    You are aware that, unlike perm gen size, the metaspace is effectively unlimited in size by default, right? The most common reason to set it in the past was to increase that limit, which is not necessary anymore. – the8472 Jul 15 '15 at 22:00
  • Yes, but the Metaspace is now in native memory. Without a max, it can potentially grow to consume all system memory (and end up spilling into the swap space). – LimaNightHawk Jul 16 '15 at 00:17
  • 1
    @LimaNightHawk, so you think it's better if your Tomcat server crashes with `OutOfMemoryError` instead of (possible) swapping? – Tagir Valeev Jul 16 '15 at 02:15
  • Ok, good push back, enough for me to create [this](http://stackoverflow.com/questions/31455644/should-i-set-a-maxmetaspacesize) question. Perhaps the rest of the comments and (hopefully) answers can focus on "how" not "why". – LimaNightHawk Jul 16 '15 at 13:37

0 Answers0