Could you help me solve the following problem:
Context:
We are trying to port our existing application, which currently runs on Java6 (on Glassfish), for production in Java8 (on Jetty9). Previously, we were able to successfully migrate the same configuration to Java7 (on Jetty9). But the client decided to go with Java 8 now. In this process, we encountered some memory problems, and the following are the details:
Description of the problem:
After starting the Jetty server, the use of initial (RES) memory in the Java process is about 5.5 g. After starting the application for some time, the memory usage is slow and consumes the maximum available physical memory (8 g) on the machine, which leads to server / failure system.
This problem is found only in linux environment. There are no such problems in the Windows environment.
Conclusions of the expert:
Server monitoring using VisualVM and jconsole. In both profiles of JVM memory (heap and not heap), usage is limited.
Environmental Information:
Java Version : 8
Server : Jetty 9.2.10
OS : linux on a virtual machine(Linux version 2.6.32-279.14.1.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Tue Nov 6 23:43:09 UTC 2012
Java Options :
-Xms3072M
-server
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:+UseG1GC
-XX:MaxGCPauseMillis=75
-Xmx3072M
-Xss1024K
-XX:InitialCodeCacheSize=192M
-XX:CodeCacheExpansionSize=3M
-XX:CodeCacheMinimumFreeSpace=3M
-XX:ReservedCodeCacheSize=600M
-XX:MinMetaspaceExpansion=3M
-XX:MaxMetaspaceExpansion=18M
-XX:MaxMetaspaceSize=500M
-XX:MaxDirectMemorySize=288M
-XX:CompressedClassSpaceSize=512M
-XX:ParallelGCThreads=12
-XX:ConcGCThreads=4
-Dsun.rmi.dgc.server.gcInterval=86400000
-Dsun.rmi.dgc.client.gcInterval=86400000
PS: Do not put it as a duplicate. I read a lot of answers on stackoverflow, but nothing touched or solved my problem.
Update
I started the jetty with the following Java parameters, and since then, memory usage has been between 4.5 g and 4.8 g (approximately 142 hours). It looks stable to me. I reserved about 2 g of memory using the java option flags (Xmx and MetaspaceSize), but 2.5 g is additionally used. Is this normal behavior for Java 8 on a Linux machine?
Java options:
-server
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=../logs/jvm.log
-XX:+UseG1GC
-XX:MaxGCPauseMillis=75
-XX:ParallelGCThreads=12
-XX:ConcGCThreads=12
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-Xloggc:../logs/gc.log
-XX:NativeMemoryTracking=summary
-Xmx1500m
-Xss256k
-XX:MaxMetaspaceSize=512m
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/opt/logs/jetty.hprof
-Dsun.rmi.dgc.server.gcInterval=86400000
-Dsun.rmi.dgc.client.gcInterval=86400000
Thank you for your time!