I think I may have a memory leak in a servlet application running in production on jetty 8.1.7.
- Is there a way of seeing how much heap memory is actually being used at an instance of time, not the max memory allocated with -Xmx, but the actual amount of memory being used.
- Can I force a garbage collection to occur for an application running within jetty
yes, both are easily achievable using:
VisualVM(see: http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/monitor_tab.html) This one is shipped with Oracle JDK by default (=> no extra installation required)However for the memory leak detection, I’d suggest to do memory dump and analyze it later with
eclipse MAT( http://www.eclipse.org/mat/ ) as it has quite nice UI visualizing java memory dumps.EDIT:
For the ssh only access, yes you can use the mentioned two tools. However you need to run them on the machine with running window manager and remotely connect over ssh to the other machine (you need to have java on both of these machines):
visualVM: you need to haveVisualVMrunning on one maching and via the ssh connect to remote one, see: VisualVM over sshjmap(for sample usage see: http://kadirsert.blogspot.de/2012/01/…) afterwards download the dump file and load if locally toeclipse MAT