line Tool to find Java Heap Size and Memory Used (Linux)?
Is there a Command-line Tool (Linux) to check Heap Size (and Used Memory) of a Java Application?
I have tried jmap. But it gives info. about internal memory areas like Eden/PermGen etc., which is not useful to me.
I am looking for something like:
Max Memory: 1GB
Min Memory: 256 MB
Heap Memory: 700 MB
Used Memory: 460 MB
Thats all. I know i can see this in JConsole etc., but i need a command-line tool (cannot enable JMX etc.)
Any such tool/command?
Each Java process has a pid
, which you first need to find with the jps
command.
Once you have the pid, you can use jstat -gc [insert-pid-here]
to find statistics of the behavior of the garbage collected heap.
jstat -gccapacity [insert-pid-here]
will present information about memory pool generation and space capabilities.
jstat -gcutil [insert-pid-here]
will present the utilization of each generation as a percentage of its capacity. Useful to get an at a glance view of usage.
See jstat docs on Oracle's site.
jvmtop is a command-line tool which provides a live-view at several metrics, including heap.
Example output of the VM overview mode:
JvmTop 0.3 alpha (expect bugs) amd64 8 cpus, Linux 2.6.32-27, load avg 0.12
http://code.google.com/p/jvmtop
PID MAIN-CLASS HPCUR HPMAX NHCUR NHMAX CPU GC VM USERNAME #T DL
3370 rapperSimpleApp 165m 455m 109m 176m 0.12% 0.00% S6U37 web 21
11272 ver.resin.Resin [ERROR: Could not attach to VM]
27338 WatchdogManager 11m 28m 23m 130m 0.00% 0.00% S6U37 web 31
19187 m.jvmtop.JvmTop 20m 3544m 13m 130m 0.93% 0.47% S6U37 web 20
16733 artup.Bootstrap 159m 455m 166m 304m 0.12% 0.00% S6U37 web 46
This command shows the configured heap sizes in bytes.
java -XX:+PrintFlagsFinal -version | grep HeapSize
It works on Amazon AMI on EC2 as well.
链接地址: http://www.djcxy.com/p/14524.html