What is the best way howto monitor usage of Eden and Survivor heap spaces?
I have all the GC logging options on but I can see only YoungGen occupation:
-XX:+PrintTenuringDistribution -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log -server -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Xloggc:gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -showversion -XX:+PrintClassHistogramBeforeFullGC -XX:+PrintClassHistogramAfterFullGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=15
I would use VisualGC but cannot find its distribution anywhere. The default distribution of VisualVM that comes with JDK does not come with VisualGC. The VisualGC plugin links to the VisualGC site are broken.
UPDATE: jstat is what I was looking for, specifically :
jstat -gcutil -t <pid> <interval> <number_of_samples>
Depending on what you mean by "monitor", you might just need jstat. Check out the -gc* options.
If I understand you correctly, I think you can use JVisualVM to monitor your Java applications.
According to this page, you can download the relevant plugin center "updates.xml" file, an install it per the instructions. Then you can install the VisualGC plugin.
But the page also says that you should simply be able to install plugins using "Tools | Plugins | Available Plugins".
The links to projects on java.net are often broken in my experience. You typically have to look harder to find stuff that is hosted there.
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
Environment: Windows Server 2003 x86 Intel Xeon 2.3 4gb Ram | tomcat 7.0.27 | jdk 1.7.0.25
I am facing the OutOfMemoryError. SO suggests using java options to increase the permgen space using following options
-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC
However tomcat status page still shows the permgen memory as 64MB. Why cant it pick up the value specified in the parameters?
There is no PermGen in the status page, see this http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Introduction.
Anyways you conf seems OK
Since PermGen is a java thing (not tomcat) you should use java tools to check it, take a look at this.
As your settings seem ok, check the way you apply them: If you start tomcat via batch file, create setenv.bat with the content
CATALINA_OPTS="-Dyour-settings-from-above ... all of them"
If you start a service, you'll need to update the service configuration - as I'm not on Windows, it's a long time since I did that. Did you use the tomcatw.exe to create/configure the service? Not sure...
According to documentation one could automatically take a heap dump when the application encounters an OutOfMemoryException.
After OutOfMemoryException process just disappear from left menu.
How does this feature works in VisualVM?
Thanks.
C:\work\temp>java -XX:HeapDumpPath=c:/work/temp/file.hprof -XX:+HeapDumpOnOutOfMemoryError -jar example.jar
As far as I know, that option in JVisualVM is equivalent to specifying -XX:+HeapDumpOnOutOfMemoryError as a JVM parameter. This causes the JVM to create a heap dump file when it encounters an OutOfMemoryError. This file can be then loaded into JVisualVM (or into a profiler) and analyzed there. The directory where the file is stored is defined by the -XX:HeapDumpPath parameter.
See also:
Troubleshooting Guide for Java SE 6 with HotSpot VM
Java HotSpot VM Options
StackOverflow: Using HeapDumpOnOutOfMemoryError parameter
Seems application just exited upon OOM. In this case, you must run your app with special -XX params. See "dump" params in JVM documentation. After application dies, you can examine dump in your tool.
I have a running jvm process and I want a tool to get classes loaded by that jvm, are there one?
You can use jmap -histo <PID>
It'll show histogram of loaded classes including classname, number of instances, size, etc
jinfo <pid>
will give you quite a bit information, including the classpath and the jars in the path.
see here
The jinfo command may be limited by the permissions granted to the principal running the command. The command will only list the JVMs for which the principle has access rights as determined by operating system specific access control mechanisms.
Note also that jinfo is not available on windows or linux itanium.
You can use the following in the command line
java -verbose:class ....
and the JVM will dump out what it's loading including all its locations
try visual VM. It is free but is not distributed with JRE/JDK but you can download it from official oracle website. Also you can make a heap dump and than you can view it by standard tools from JDK.
If the process has JMX enabled then you can use jvisualvm (bundled with the JDK) to examine such properties.
I use Windows Vista , 4GB RAM , Core2
I have tested with this idea.exe.vmoptions :
-Xms64m
-Xmx512m
-XX:MaxPermSize=256m
-ea
-agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=IntelliJIdea90
The -Xmx256M option is hardcoded at the moment and there is no way to change it. There is a related discussion in the IDEA forum. If you need a way to specify heap size, please file a feature request.
Stupid I am : I have found on run configuration VM parameters and I have set "-XX:MaxPermSize=1024m -Xmx1024M -server"