1. Memory Analysis
1.1 jmap-histo command
PID = 'jps | awk' {if ($2 = "JPs") Print $1 }''
Jmap-histo $ pid> 1.txt
Num # instances (number of instances) # bytes (byte) Class Name
Explanation of Class Name
B Represents byte
C Represents char
D stands for double
F stands for float
I Represents int
J stands for long
Z represents Boolean
The front side has [representing arrays, and [I is equivalent to int []
The object is represented by a [L + class name
If the number of classes is very large, you have to check whether the memory overflows.
1.2 command jmap-heap
Jmap-heap 22792
Attaching to process ID 22792, please wait...
Debugger Attached successfully.
Server compiler detected.
JVM version is 19.0-b09
Using thread-local object allocation.
Parallel GC with 8 thread (s)
Heap Configuration:
Minheapfreeratio = 40 # corresponding JVM startup parameter-XX: minheapfreeratio sets the minimum JVM heap idle ratio (40 by default)
Maxheapfreeratio = 70 # corresponding JVM startup parameter-XX: maxheapfreeratio sets the maximum JVM heap idle ratio (70 by default)
Maxheapsize = 10737418240 (10240.0 MB) # set the maximum JVM heap size for the corresponding JVM startup parameter-XX: maxheapsize
Newsize = 5368709120 (5120.0 MB) # corresponding JVM startup parameter-XX: newsize sets the default size of the JVM heap young generation
Maxnewsize = 5368709120 (5120.0 MB) # corresponding JVM startup parameter-XX: maxnewsize sets the maximum size of the JVM heap young band
Oldsize = 5439488 (5.1875 MB) # corresponding to the JVM startup parameter-XX: oldsize sets the size of the JVM heap in the old age
Newratio = 2 # corresponding JVM startup parameter-XX: Ratio of the newratio age to the young generation
Required vorratio = 8 # Corresponds to the JVM startup parameter-XX: Required vorratio sets the ratio of Eden to vor in the young generation.
Permsize = 21757952 (20.75 MB) # specify the initial size of the persistent tape of the JVM heap according to the JVM startup parameter-XX: permsize.
Maxpermsize = 1073741824 (1024.0 MB) # corresponding JVM startup parameter-XX: maxpermsize sets the maximum size of the permanent generation of the JVM heap
Heap usage:
PS young generation
Eden space: # Percentage of memory in the Eden area that has been used for idle usage
Capacity = 5357305856 (5109.125 MB)
Used = 1647437208 (1571.118553161621 MB)
Free = 3709868648 (3538.006446838379 MB)
30.751225565270396% used
From space: # one of them has VOR (s? R? VA? V? R) the total memory distribution in the zone has used the idle usage ratio.
Capacity = 5898240 (5.625 MB)
Used = 2375696 (2.2656402587890625 MB)
Free = 3522544 (3.3593597412109375 MB)
40.278049045138886% used
To space: # The total memory distribution in the VOR area of another region is in idle usage ratio.
Capacity = 5505024 (5.25 MB)
Used = 0 (0.0 MB)
Free = 5505024 (5.25 MB)
0.0% used
PS old generation # The total memory distribution in the old age has used the idle usage ratio.
Capacity = 5368709120 (5120.0 MB)
Used = 181392168 (172.98905181884766 MB)
Free = 5187316952 (4947.010948181152 MB)
3.3786924183368683% used
PS perm generation # Percentage of the current persistent generation memory used for idle usage
Capacity = 72286208 (68.9375 MB)
Used = 72213176 (68.86785125732422 MB)
Free = 73032 (0.06964874267578125 MB)
99.89896827898346% used
1.3
Jstat-gcutil [pid] [internal] is very useful
S0: Percentage of used space in vor space 0
S1: Percentage of used space in vor space 1
E: Percentage of space used in the Eden space area
O: Percentage of space used in the old space area
P: Percentage of space used in the perm space area
Ygc: Number of young GC times
Ygct: The time unit in seconds used by young GC
FGC: number of full GC times
Fgct: the unit of time in seconds for full GC
GCT: Total time unit for garbage collection in seconds
1.4
Reduce the number of full GC times as much as possible, because the consumption of full GC is greater than that of monitor GC.
Young Generation size: set as big as possible to reduce the number of GC times for young generation and reduce the number of objects for old generation?
The minimum value of the stack allocation should be equal to the maximum value, because dynamic allocation also takes time. For example, the minimum value of the young generation and old generation can be set to the same.
Reference
Http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
JVM monitoring and memory Analysis