[linux@001]$ free --help
Usage:
free [options]
Options:
-b, --bytes show output in bytes
-k, --kilo show output in kilobytes
-m, --mega show output in megabytes
-g, --giga show output in gigabytes
--tera show output in terabytes
-h, --human show human-readable output
--si use powers of 1000 not 1024
-l, --lohi show detailed low and high memory statistics
-t, --total show total for RAM + swap
-s N, --seconds N repeat printing every N seconds
-c N, --count N repeat printing N times, then exit
-w, --wide wide output
--help display this help and exit
-V, --version output version information and exit
free命令示例
[linux@001]$ free -b
total used free shared buff/cache available
Mem: 16657858560 9096298496 5962731520 42442752 1598828544 7198982144
Swap: 0 0 0
[linux@001]$ free -k
total used free shared buff/cache available
Mem: 16267440 8884816 5821264 41448 1561360 7028544
Swap: 0 0 0
[linux@001]$ free -m
total used free shared buff/cache available
Mem: 15886 8757 5612 40 1516 6782
Swap: 0 0 0
[linux@001]$ free -g
total used free shared buff/cache available
Mem: 15 8 5 0 1 6
Swap: 0 0 0
[linux@001]$ free -h
total used free shared buff/cache available
Mem: 15G 8.6G 5.5G 40M 1.5G 6.6G
Swap: 0B 0B 0B
[linux@001]$ free -l -h
total used free shared buff/cache available
Mem: 15G 8.5G 5.6G 40M 1.5G 6.7G
Low: 15G 9G 5.6G
High: 0B 0B 0B
Swap: 0B 0B 0B
[linux@001]$ free -t -h
total used free shared buff/cache available
Mem: 15G 8.5G 5.6G 40M 1.5G 6.7G
Swap: 0B 0B 0B
Total: 15G 8.5G 5.6G
[linux@001]$ free -s 10
total used free shared buff/cache available
Mem: 16267440 8910116 5798884 41448 1558440 7003268
Swap: 0 0 0
total used free shared buff/cache available
Mem: 16267440 8912052 5796892 41448 1558496 7001336
Swap: 0 0 0
-class: Statistics on the behavior of the class loader.
-compiler: Statistics of the behavior of the HotSpot Just-in-Time compiler.
-gc: Statistics of the behavior of the garbage collected heap.
-gccapacity: Statistics of the capacities of the generations and their corresponding spaces.
-gccause: Summary of garbage collection statistics (same as -gcutil), with the cause of the last and current (if applicable) garbage collection events.
-gcnew: Statistics of the behavior of the new generation.
-gcnewcapacity: Statistics of the sizes of the new generations and its corresponding spaces.
-gcold: Statistics of the behavior of the old and permanent generations.
-gcoldcapacity: Statistics of the sizes of the old generation.
-gcpermcapacity: Statistics of the sizes of the permanent generation.
[linux@001]$ jmap -h
Usage:
jmap [option] <pid>
(to connect to running process)
jmap [option] <executable <core>
(to connect to a core file)
jmap [option] [server_id@]<remote server IP or hostname>
(to connect to remote debug server)
where <option> is one of:
<none> to print same info as Solaris pmap
-heap to print java heap summary
-histo[:live] to print histogram of java object heap; if the "live"
suboption is specified, only count live objects
-clstats to print class loader statistics
-finalizerinfo to print information on objects awaiting finalization
-dump:<dump-options> to dump java heap in hprof binary format
dump-options:
live dump only live objects; if not specified,
all objects in the heap are dumped.
format=b binary format
file=<file> dump heap to <file>
Example: jmap -dump:live,format=b,file=heap.bin <pid>
-F force. Use with -dump:<dump-options> <pid> or -histo
to force a heap dump or histogram when <pid> does not
respond. The "live" suboption is not supported
in this mode.
-h | -help to print this help message
-J<flag> to pass <flag> directly to the runtime system
jmap命令示例
[linux@001]$ netstat -npl | grep 8889
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::8889 :::* LISTEN 7253/java
[linux@001]$ jmap -heap 7253
Attaching to process ID 7253, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.65-b01
using thread-local object allocation.
Parallel GC with 8 thread(s)
Heap Configuration: #堆配置,即JVM参数配置
MinHeapFreeRatio = 0 #最小堆使用比例
MaxHeapFreeRatio = 100 #最大堆使用比例
MaxHeapSize = 4164943872 (3972.0MB) #最大堆空间大小
NewSize = 87031808 (83.0MB) #新生代分配大小
MaxNewSize = 1388314624 (1324.0MB) #最大新生代可分配大小
OldSize = 175112192 (167.0MB) #老年代大小
NewRatio = 2 #新生代比例
SurvivorRatio = 8 #新生代和survivor比例
MetaspaceSize = 21807104 (20.796875MB) #元数据空间大小
CompressedClassSpaceSize = 1073741824 (1024.0MB) #指针空间大小
MaxMetaspaceSize = 17592186044415 MB #MaxMetaspaceSize=Compressed Class Space Size + Metaspace area (excluding the Compressed Class Space) Size
G1HeapRegionSize = 0 (0.0MB) #G1中的region大小
Heap Usage:
PS Young Generation
Eden Space: #eden区
capacity = 1342177280 (1280.0MB)
used = 970477176 (925.519157409668MB)
free = 371700104 (354.48084259033203MB)
72.30618417263031% used
From Space: #from区,即survivor1区
capacity = 23068672 (22.0MB)
used = 22904896 (21.84381103515625MB)
free = 163776 (0.15618896484375MB)
99.29005015980114% used
To Space: #to区,即survivor2区
capacity = 23068672 (22.0MB)
used = 0 (0.0MB)
free = 23068672 (22.0MB)
0.0% used
PS Old Generation #老年代使用情况
capacity = 176685056 (168.5MB)
used = 52151696 (49.73573303222656MB)
free = 124533360 (118.76426696777344MB)
29.5167555087398% used
31742 interned Strings occupying 3385416 bytes.