JAVA内存分析

内存分析

查看启动的JVM

jps -lv
  • jps -lv 会显示详细的启动参数

查看jvm内存使用情况

$ jmap -heap [pid]

Attaching to process ID 32684, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.73-b02

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC

Heap Configuration:
   MinHeapFreeRatio         = 40    #-XX:MinHeapFreeRatio设置JVM堆最小空闲比率,小于这个比例进行收缩  
   MaxHeapFreeRatio         = 70	#-XX:MaxHeapFreeRatio 大于这个比例时进行扩张
   MaxHeapSize              = 1073741824 (1024.0MB)	#-XX:MaxHeapSize=设置JVM堆的最大大小
   NewSize                  = 536870912 (512.0MB) #-XX:NewSize=设置JVM堆的‘新生代’的默认大小
   MaxNewSize               = 536870912 (512.0MB) #-XX:MaxNewSize=设置JVM堆的‘新生代’的最大大小
   OldSize                  = 536870912 (512.0MB) #-XX:OldSize=设置JVM堆的‘老生代’的大小
   NewRatio                 = 2 #-XX:NewRatio=:‘新生代’和‘老生代’的大小比率
   SurvivorRatio            = 8	#-XX:SurvivorRatio=设置年轻代中Eden区与Survivor区的大小比值
   MetaspaceSize            = 134217728 (128.0MB)	#元空间。执久代的替代物,不限制于JVM,跟随主机内存
   CompressedClassSpaceSize = 1073741824 (1024.0MB) #类指针压缩空间大小, 默认为1G
   MaxMetaspaceSize         = 134217728 (128.0MB) #最大元空间。执久代的替代物,不限制于JVM,跟随主机内存
   G1HeapRegionSize         = 0 (0.0MB) #G1收集器的分割大小

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 483196928 (460.8125MB)
   used     = 30644984 (29.22533416748047MB)
   free     = 452551944 (431.58716583251953MB)
   6.342131380437915% used
Eden Space:
   capacity = 429522944 (409.625MB)
   used     = 30644984 (29.22533416748047MB)
   free     = 398877960 (380.39966583251953MB)
   7.134655884645827% used
From Space:
   capacity = 53673984 (51.1875MB)
   used     = 0 (0.0MB)
   free     = 53673984 (51.1875MB)
   0.0% used
To Space:
   capacity = 53673984 (51.1875MB)
   used     = 0 (0.0MB)
   free     = 53673984 (51.1875MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 536870912 (512.0MB)
   used     = 13905552 (13.261367797851562MB)
   free     = 522965360 (498.73863220214844MB)
   2.5901108980178833% used

14836 interned Strings occupying 1399472 bytes.

内存对象分析

jmap -histo [pid] > jmap.log

将内存对象信息生成文件进行分析。打开文件可以看到具体哪个对象占用内存比较高


 num     #instances         #bytes  class name
----------------------------------------------
   1:        184324       35712968  [C
   2:          4763       32669032  [I
   3:        502587       16082784  java.util.concurrent.locks.AbstractQueuedSynchronizer$Node
   4:          8040        2732960  [B
   5:         79620        1910880  java.lang.String
   6:          8690         966528  java.lang.Class
   7:         10627         833352  [Ljava.lang.Object;
   8:         24552         785664  java.util.concurrent.ConcurrentHashMap$Node
   9:         31100         746400  java.lang.StringBuilder
  10:         15275         488800  java.lang.StackTraceElement
  11:          5504         484352  java.lang.reflect.Method
  12:         20939         335024  java.lang.Object
  13:          5627         315112  java.util.LinkedHashMap
  14:           212         280056  [Ljava.util.concurrent.ConcurrentHashMap$Node;
  15:          6571         262840  java.util.LinkedHashMap$Entry
  16:          7376         236032  java.lang.ref.WeakReference
  17:          2833         228160  [Ljava.util.HashMap$Node;
  18:          5524         226392  [Ljava.lang.String;
  19:          6738         215616  java.util.HashMap$Node
  20:          5226         209040  java.util.HashMap$KeyIterator
  21:          1770         169920  java.lang.management.ThreadInfo
  22:          3988         159520  java.lang.ref.SoftReference
  23:          1292         144704  org.springframework.boot.loader.jar.JarEntry
  24:          4799         115176  java.util.ArrayList
  25:          2876         115040  java.util.TreeMap$Entry
  26:          1825          95360  [Ljava.lang.StackTraceElement;
  27:          3231          77544  java.beans.MethodRef
  28:          1367          76552  java.beans.MethodDescriptor
  29:          3157          67864  [Ljava.lang.Class;
  30:          1294          62112  java.util.HashMap
  31:          1205          59600  [Z
  32:           856          54384  [S
  33:            78          51168  io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueue
  34:           795          50880  java.net.URL
  35:          1043          50064  org.aspectj.weaver.reflect.ShadowMatchImpl
  36:           623          49840  java.lang.reflect.Constructor
  • num 排名
  • instances 实例数
  • bytes 占用内存大小 单位B
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值