I am trying GC log rotation in JDK 8.So I have achieved it by using below GC Log JVM parameter
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:verbose-jdk8-gc.log -XX:+PrintGCDateStamps
-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=1k
But Now I want that This should also compressed when Rotation is done.
So is there any JVM Parameter in JDK 8 for compression of GC Log ?
Is there any one who can help me.
On Linux, you can use logroate: https://linux.die.net/man/8/logrotate to manage the rotation and compression of JVM gc log.
Related
I need some guidance related to Java 11 GC algorithm for JVM. We are migrating our application from jdk 8 to Java11. We are seeing spikes in memory management with the new GC algorithm that is defaulted with Java11 ie., GC1. Earlier we used CMS. Earlier our JVM startup params for the GC as below:
Application Infrastructure : 8 core CPU, 16GB RAM Linux EC2 (c5.2xlarge)
JDK 8 : -d64 -server -Xms4g -Xmx12g -XX:NewRatio=1 -XX:SurvivorRatio=4 -verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseConcMarkSweepGC -XX:ThreadStackSize=1024 -XX:+OptimizeStringConcat -XX:CMSInitiatingOccupancyFraction=70
Here we see the average memory usage at 4gb to 6gb when there is full load on the system.
Java11 : -server -Xms12g -Xmx12g -verbose:gc -Xlog:gc:gc.log -XX:+PrintGCDetails -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=30 -XX:G1ReservePercent=20 -XX:+UseStringDeduplication -Xlog:safePoint -XX:ThreadStackSize=1024 -XX:+OptimizeStringConcat
Here we see the average memory usage gradually increase and go up till 90% on full load and that's when the GC runs and frees up the space. Also, we do not see the memory usage coming down when there is no load or 0 load on the system. I read that this is the expected behavior of Gc1
Kindly Advice!
Application behavior is similar is both cases
I want to modify the maximum heap size through jinfo.
jinfo -flag MaxHeapSize=3122032640 <pid>
Since AdaptiveSizePolicy is enabled by default, modifying flags directly will result in an exception. So I disabled AdaptiveSizePolicy when the process started.
java -XX:-UseAdaptiveSizePolicy Sleep.java
I can also get the right result through jinfo
jinfo -flag UseAdaptiveSizePolicy 18220
-XX:-UseAdaptiveSizePolicy
But when I modify the maximum heap memory through jinfo again, exceptions will still occur.
jinfo -flag MaxHeapSize=3122032640 18220
Exception in thread "main" com.sun.tools.attach.AttachOperationFailedException: flag 'MaxHeapSize' cannot be changed
at jdk.attach/sun.tools.attach.VirtualMachineImpl.execute(VirtualMachineImpl.java:224)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:309)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:282)
at jdk.jcmd/sun.tools.jinfo.JInfo.flag(JInfo.java:146)
at jdk.jcmd/sun.tools.jinfo.JInfo.main(JInfo.java:127)
It seems that -XX:-UseAdaptiveSizePolicy is not effective.
Does anyone know the reason?
I know the -Xmx flag to set the maximum heap size.
JDK: openjdk 13.0.1
OS: Ubuntu 18.04
VM flags:
-XX:CICompilerCount=3 -XX:ConcGCThreads=1 -XX:G1ConcRefinementThreads=4 -XX:G1HeapRegionSize=1048576 -XX:GCDrainStackTargetSize=64 -XX:InitialHeapSize=134217728 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=536870912 -XX:MaxNewSize=321912832 -XX:MinHeapDeltaBytes=1048576 -XX:MinHeapSize=134217728 -XX:NonNMethodCodeHeapSize=5830732 -XX:NonProfiledCodeHeapSize=122913754 -XX:ProfiledCodeHeapSize=122913754 -XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache -XX:SoftMaxHeapSize=536870912 -XX:-UseAdaptiveSizePolicy -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:+UseG1GC
I want to modify the maximum heap size through jinfo.
It is not possible. MaxHeapSize is not manageable flag, it cannot be changed in runtime.
-XX:UseAdaptiveSizePolicy flag is completely different thing. If configures whether GC may resize heap generations basing on the GC statistics, in order to achieve pause/throughput/footprint goals.
Our application runs 24*7 with heavy user load, recnlty we started having issues with system performance, application not responding, we had to restart JVM to get it back online while investigating we found out that JVM runs GC and at that time application slows down, sometime not even responding,
Below is our stats for GC during that time.
GC Heap
GC Summary
Looking at this data, is there any recommendations on what to look for or if any JVM configuration needs to be corrected?
Java Version is 7, GC settings are #jvm -XX:+UseConcMarkSweepGC -XX:-UseGCOverheadLimit -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintGCDateStamps -Xloggc:/opt/Server/logs/gclog.log -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Xms4096M -Xmx6144M -XX:PermSize=512M -XX:MaxPermSize=1024M -XX:ErrorFile=./log/error.log -XX:HeapDumpPath=./log/heap_dump.hprof –
I want to understand the difference between:
-XX:+PrintGC and -verbose:gc
Apparently these look similar.
This article doesn't list the verbose:gc
http://www.oracle.com/technetwork/articles/java/vmoptions-jsp-140102.html
I also saw these two questions: How to redirect verbose garbage collection output to a file? and https://stackoverflow.com/a/1818039/2266682
but couldn't get much understanding.
In JDK 8 -verbose:gc is an exact alias for -XX:+PrintGC.
However, -verbose:gc is a standard option, while -XX:+PrintGC is not.
-XX:+PrintGC is deprecated since JDK 9 in favor of unified logging option -Xlog:gc, see JEP 158.
-verbose:gc still works in JDK 9 and 10.
i am working on Struts1.x web application and using weblogic server, when performing some processing on very huge data, it consume almost all the RAM but after completing or session timeout, it don't return the consumed RAM.
It never release the RAM until I stop the server or kill forcefully. wanted to know such scenario where the RAM utilization is not released after usage and if it can be solve by tuning weblogic paramter or by some other way.
using the following parameter in weblogic:
-Xms12g -Xmx12g -XX:MetaspaceSize=1G -XX:MaxMetaspaceSize=1G
-XX:NewRatio=3 -XX:SurvivorRatio=8 -XX:+UseCompressedOops
-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+DisableExplicitGC
-XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSClassUnloadingEnabled
-XX:+CMSScavengeBeforeRemark -XX:CMSInitiatingOccupancyFraction=68
-DBASE_CONFIG_LA=/data01/Lending_Analytics_weblogic/LendingAnalyticsPQM/config/
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+HeapDumpOnOutOfMemoryError
-XX:+UseGCOverheadLimit -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2m -Xloggc:/data01/Lending_Analytics_weblogic/LendingAnalyticsPQM/GCLogs/gc.log
*** not able to find any GC issue after analyzing the GC logs.
*** fixed all the Memory Leak issue from the code through eclipse memory leak compiler