java高分局之jmap命令使用

11 篇文章 0 订阅
1 篇文章 0 订阅

java高分局之jmap命令使用

此命令可以用来查看内存信息。

实例个数以及占用内存大小

C:\Users\Administrator>jmap -histo 4284  > d:/log.txt

打开log.txt,文件内容如下:

 num     #instances         #bytes  class name
----------------------------------------------
   1:       1496092      127664200  [C
   2:        157665       46778984  [I
   3:        100289       25426744  [B
   4:        736941       17686584  java.util.HashMap$Node
   5:         74396       11077256  [Ljava.util.HashMap$Node;
   6:        192701       10228688  [J
   7:        564943        9039088  java.lang.String
   8:         83340        8667360  org.eclipse.jdt.internal.compiler.ast.MethodDeclaration
   9:        125450        7025200  org.eclipse.jdt.internal.compiler.ast.SingleNameReference
  10:        125867        6903952  [Ljava.lang.Object;
  11:         67093        6440928  org.eclipse.jdt.internal.compiler.ast.MessageSend
  12:        188979        6183520  [[C
  13:        116393        5586864  org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference
  14:         77426        5574672  org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl
  15:         49078        5104112  org.eclipse.jdt.internal.compiler.lookup.MethodScope
  16:         90784        4357632  org.eclipse.jdt.internal.compiler.ast.SingleTypeReference
  17:         85628        3275744  [Ljava.lang.String;
  18:         49565        3172160  org.eclipse.jdt.internal.compiler.lookup.MethodBinding
  .......
  • num:序号
  • instances:实例数量
  • bytes:占用空间大小
  • class name:类名称

堆信息

C:\Users\Administrator>jmap -heap 4284
Attaching to process ID 4284, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 25.0-b70

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

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 1073741824 (1024.0
   NewSize                  = 419430400 (400.0MB
   MaxNewSize               = 419430400 (400.0MB
   OldSize                  = 654311424 (624.0MB
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 104857600 (100.0MB
   CompressedClassSpaceSize = 52428800 (50.0MB)
   MaxMetaspaceSize         = 104857600 (100.0MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 377487360 (360.0MB)
   used     = 346767024 (330.7028045654297MB)
   free     = 30720336 (29.297195434570312MB)
   91.8618901570638% used
Eden Space:
   capacity = 335544320 (320.0MB)
   used     = 317925456 (303.1973419189453MB)
   free     = 17618864 (16.802658081054688MB)
   94.74916934967041% used
From Space:
   capacity = 41943040 (40.0MB)
   used     = 28841568 (27.505462646484375MB)
   free     = 13101472 (12.494537353515625MB)
   68.76365661621094% used
To Space:
   capacity = 41943040 (40.0MB)
   used     = 0 (0.0MB)
   free     = 41943040 (40.0MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 654311424 (624.0MB)
   used     = 190777600 (181.939697265625MB)
   free     = 463533824 (442.060302734375MB)
   29.157002766927082% used

32953 interned Strings occupying 2775672 bytes.

如果对堆内存有一些了解的话,应该能看的明白这些输出的意思。

即将垃圾回收对象个数

C:\Users\Administrator>jmap -finalizerinfo 4284
Attaching to process ID 4284, please wait...
Debugger attached successfully.
Client compiler detected.
JVM version is 25.0-b70
Number of objects pending for finalization: 0

堆内存dump

C:\Users\Administrator>jmap -dump:format=b,file=D:/chu 4284
Dumping heap to D:\chu ...
Heap dump file created

我们可以用jhat命令来查看此dump文件的内容

C:\Users\Administrator>jhat -J-Xmx500m D:/chu
Reading from D:/haha...
Dump file created Thu May 28 09:46:36 CST 2015
Snapshot read, resolving...
Resolving 3915212 objects...
Chasing references, expect 783 dots.......................
..........................................................
..........................................................
..........................................................
..................
Eliminating duplicate references..........................
..........................................................
..........................................................
..........................................................
...............
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.

然后在浏览器中输入:http://localhost:7000来查看堆中的对象信息

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值