0

I'm using a tomcat:8 inside docker. This are some important settings (default).

$ java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
Picked up JAVA_TOOL_OPTIONS: -Duser.home=/home/jboss -Duser.name=jboss
     intx CompilerThreadStackSize                   = 0                                   {pd product}
    uintx ErgoHeapSizeLimit                         = 0                                   {product}
    uintx HeapSizePerGCThread                       = 87241520                            {product}
    uintx InitialHeapSize                          := 33554432                            {product}
    uintx LargePageHeapSizeThreshold                = 134217728                           {product}
    uintx MaxHeapSize                              := 524288000                           {product}
     intx ThreadStackSize                           = 1024                                {pd product}
     intx VMThreadStackSize                         = 1024                                {pd product}

Now I need to increase the max heapsize because I get some problems with outofmemory issues. (The applications are pretty heavy).

Before it goes out of memory it's warning me that the max heapsize is nearly reached and that the tomcat will go outofmemory. A few minutes later it's crashing.

Inside my tomcat are a couple of .war's deployed. The apps are in /deployments/xxx.war.

ls shows me

app1_0.1                                               
app1_0.1.war                                           
app2_0.1                                       
app2_0.1.war
...

Now my question is the following. Do I have to increase the heapsize for every .war file seperatly or for the whole tomcat at the same moment. Because I don't find a command to check the heapsize on one java application but when I want to increase the heapsize I only seem to find command like this: java -Xms16m -Xmx64m ClassName (so on one specific application).

When I just execute it without specifying an app:

$ java -Xms16m -Xmx64m
Picked up JAVA_TOOL_OPTIONS: -Duser.home=/home/jboss -Duser.name=jboss
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32      use a 32-bit data model if available
    -d64      use a 64-bit data model if available
    -server   to select the "server" VM
                  The default VM is server,
                  because you are running on a server-class machine.
...
DenCowboy
  • 13,884
  • 38
  • 114
  • 210

2 Answers2

0

Try increasing the perm size as well: -XX:MaxPermSize=256m

This will add 256mb to your heap size when your app needs it.

spock
  • 95
  • 1
  • 12
  • Can you give me the exact command? I tried `java -XX:MaxPermSize=256m` but didn't work: `OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0` – DenCowboy Nov 28 '16 at 09:48
  • JDK 8 requires that you manage meta space. Perm gen has gone away. – duffymo Dec 05 '16 at 12:39
0

Have a look at related SE question regarding solutions for OutOfMemory errors

java.lang.OutOfMemoryError: Java heap space

MaxPermSize flag has been removed with JDK 1.8. It was replaced by Metaspace.

JDK8: Metaspace

In JDK 8, classes metadata is now stored in the native heap and this space is called Metaspace. There are some new flags added for Metaspace in JDK 8:

-XX:MetaspaceSize=<NNN> where is the initial amount of space(the initial high-water-mark) allocated for class metadata (in bytes) that may induce a garbage collection to unload classes.

-XX:MaxMetaspaceSize=<NNN> where is the maximum amount of space to be allocated for class metadata (in bytes).

Have a look at oracle blog

Use -d64 option in VM parameters since you are using 64 bit OS.

VM parameters you are setting is global to tomact instance.

Community
  • 1
  • 1
Ravindra babu
  • 37,698
  • 11
  • 250
  • 211