0

I am running my java application on centos 6 with openjdk version "1.8.0_232" using G1GC. I am seeing the total heap usage grows gradually and causing application to crash. When I am taking a heapdump of live objects the dump size is only 1.6GB but my total used heap was 32GB.

Command used for taking dump: jmap -dump:live,format=b,file=/tmp/dump.hprof

Read somewhere , that the jmap dump command triggers a full GC and releases inaccessible heap , that is the reason for less dump size. I can see after triggering dump command my total heap usage came down and again it starts growing gradually.

My JVM args : -XX:-AllowUserSignalHandlers -Xmx49000m -DFCGI_PORT=6654 -XX:+UseG1GC -XX:+UseStringDeduplication -XX:InitiatingHeapOccupancyPercent=55 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/xyz -XX:+PerfDisableSharedMem -Djava.io.tmpdir=/var/XXX/temp

Is there a better way to efficiently do full GC with G1?

  • Sorry but 32GB of heap?! What kind of application are you working on?? – dpr Jul 17 '20 at 22:04
  • And what exactly do you mean by „causing the application to crash“? Is there any stackstrace or error message? I assume the first full GC with 32GB of heap will cause a nice stop-the-world event! – dpr Jul 17 '20 at 22:08
  • can you clearly explain this part? `causing application to crash`? what actually happens – Eugene Jul 18 '20 at 11:26
  • My application is an NMS application which supports very large scale of wireless/wired devices.Applications stops processing messages from controller. We save jvm statistics and if we see heap used has reached the maximum memory allocated. We have to restart application to start processing again. – ratheesh t.v. Jul 21 '20 at 10:41

1 Answers1

0

This is because what is being presented to you is the commited memory, which is different from the used memory.

In more recent versions of Java there have been improvements in the GC algorithms for the commited memory to be released more frequently for the operating system.

Use Java Mission Control to see your memory in more detail (commited memory vs used memory).

My recommendation is to use newer versions of Java, if it is not possible, change the value of XmX to a lower value (3Gb). You will notice that the JVM will always approach the defined limit.

  1. https://openjdk.java.net/jeps/346
  2. https://openjdk.java.net/jeps/351
  3. https://blog.idrsolutions.com/2019/09/improved-garbage-collection-in-java-13/
  4. https://www.slideshare.net/jelastic/choosing-right-garbage-collector-to-increase-efficiency-of-java-memory-usage
Emerson
  • 428
  • 5
  • 16
  • Used memory also reaches 32GB. See statistics_2020_07_17_08_54_03.xml:3: << -- till this point mem usage ~25-30 GB statistics_2020_07_17_09_04_06.xml:3: << -- after full GC(executed jcmd) it came to 2GB releasing 30GB Want to know is there a way to do periodic fullGC in G1GC in 1.8.0_232 version of java. I tried -XX:G1PeriodicGCInterval=3600000 & -XX:+G1PeriodicGCInvokesConcurrent but those are not supported my version – ratheesh t.v. Jul 21 '20 at 10:49
  • Can you configure XmX for 4Gb to see how the memory consumption behaves? – Emerson Jul 21 '20 at 11:10