It's all about the answers!

Ask a question

How to monitor memory usage and allocation for Java?


Sandra Bernspang (15258) | asked Oct 08 '12, 10:38 a.m.
JAZZ DEVELOPER
edited Oct 08 '12, 10:41 a.m.
Is there any way I can monitor how much memory is allocated to Java and more importantly, how much memory is being used by Java? Is there a built-in monitor? If not, what external tool would you recommend?

Comments
Daniel Pool commented Oct 08 '12, 1:09 p.m.
JAZZ DEVELOPER

Are you talking about java allocation by the server? I guess I need a little more information on your specific use case.


Sandra Bernspang commented Oct 09 '12, 4:20 a.m.
JAZZ DEVELOPER

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 commented Oct 09 '12, 4:46 a.m.
JAZZ DEVELOPER

And to clarify, I don't refer to how much is allocated, though such statistics would also be interesting to look at.

4 answers



permanent link
Benjamin Chodroff (8985231) | answered Oct 13 '12, 9:22 a.m.
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.



permanent link
Gili Mendel (1.8k56) | answered Oct 09 '12, 9:27 a.m.
JAZZ DEVELOPER
Did you try took look at the working set used by your java process (task mgr. or top/vmstat on linux)

Comments
Sandra Bernspang commented Oct 12 '12, 4:48 a.m.
JAZZ DEVELOPER

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.


Gili Mendel commented Oct 15 '12, 1:56 p.m.
JAZZ DEVELOPER

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.


permanent link
Gili Mendel (1.8k56) | answered Oct 09 '12, 9:36 a.m.
JAZZ DEVELOPER
If you have a RAM server handy, you can drop some widgets from it (Look at the extension page)



Comments
Sandra Bernspang commented Oct 12 '12, 4:49 a.m.
JAZZ DEVELOPER

Would you mind expanding on this a bit? Where can I find a RAM server and how do I use it in this context?


permanent link
Philippe Mulet (55112) | answered Oct 18 '12, 4:19 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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.


Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.