How to monitor memory usage and allocation for Java?
4 answers
You can turn on JMX monitoring at the application server level. Here are the java JVM options I use to turn it on (no password...)
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=1099
I use this with both WebSphere application server as well as Tomcat successfully in all versions of CLM. I have integrated this with logicmonitor.com's SaaS monitoring very successfully to show online dashboards of what is going on in the server. Here is a demo that we use at oncloudone.net:
https://oncloudone.logicmonitor.com/santaba/uiv2/onegadgets/index.jsp?c=oncloudone&u=demo&p=demo
Username: demo
Password: demo
All too often people forget to tune their Java settings and end up throwing a lot more hardware (CPU power) when all that is needed is a few JVM tweaks to prevent the garbage collection from running too often.
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=1099
I use this with both WebSphere application server as well as Tomcat successfully in all versions of CLM. I have integrated this with logicmonitor.com's SaaS monitoring very successfully to show online dashboards of what is going on in the server. Here is a demo that we use at oncloudone.net:
https://oncloudone.logicmonitor.com/santaba/uiv2/onegadgets/index.jsp?c=oncloudone&u=demo&p=demo
Username: demo
Password: demo
All too often people forget to tune their Java settings and end up throwing a lot more hardware (CPU power) when all that is needed is a few JVM tweaks to prevent the garbage collection from running too often.
Did you try took look at the working set used by your java process (task mgr. or top/vmstat on linux)
Comments
Well, the java.exe process in Windows only seems to show how much has been allocated to Java, as it keeps increasing with every operation. I've also noticed that it actually increases somewhat when no operation is done at all: I closed the browser and the java.exe process kept increasing. What I'm interested in is how much memory is used for each operation.
There is no simple way to monitor this, given that Java's gc may run at anytime, not to mention the heap allocation algorithm... it does not always goes down after it is ratched up.
For high level heap usage, you can simply look into the Jazz application admin page, eg: <host>/jts/admin: it will show the VM memory usage.
Another useful JVM option is to enable verbose GC (adding option -verbose:gc on JVM command line), it will log GC activity, and there are tools helping visualize it and notice memory levels, GC pauses etc...
JMX (suggested above) is another good option.
Another useful JVM option is to enable verbose GC (adding option -verbose:gc on JVM command line), it will log GC activity, and there are tools helping visualize it and notice memory levels, GC pauses etc...
JMX (suggested above) is another good option.
Comments
Daniel Pool
JAZZ DEVELOPER Oct 08 '12, 1:09 p.m.Are you talking about java allocation by the server? I guess I need a little more information on your specific use case.
Sandra Bernspang
JAZZ DEVELOPER Oct 09 '12, 4:20 a.m.I'd like to understand how much memory is being used by Java. I've set the Java heap size to 6 GB, but I'd like to understand if that is actually too much or too little to get good performance. I was thinking that some statistics on how much memory is actually used while the server is up and running, I could determine that.
Sandra Bernspang
JAZZ DEVELOPER Oct 09 '12, 4:46 a.m.And to clarify, I don't refer to how much is allocated, though such statistics would also be interesting to look at.