[Java]jhsdb查看内存内Java对象

  • java版本 (13)
  • jhsdb简介
jhsdb从java9开始引入,可执行文件放在JAVA_HOME/bin目录下, 其取代了之前的JAVA_HOME/lib/sa-jdi.jar;
clhsdb、debugd、hsdb、jstack、jmap、jinfo、jsnap这些是jhsdb命令不同的mode;
jhsdb是一种进程外的调试工具,基于Java实现的API集合,以服务性代理的形式工作,主要从HotSpot虚拟机中获取Java虚拟机的运行相关信息。
# jhsdb
    clhsdb       	command line debugger
    hsdb         	ui debugger
    debugd --help	to get more information
    jstack --help	to get more information
    jmap   --help	to get more information
    jinfo  --help	to get more information
    jsnap  --help	to get more information
  • jhsdb jmap模式查看JVM中堆对象的分配详情
# jhsdb jmap
    <no option>             To print same info as Solaris pmap.
    --heap                  To print java heap summary.
    --binaryheap            To dump java heap in hprof binary format.
    --dumpfile <name>       The name of the dump file.
    --histo                 To print histogram of java object heap.
    --clstats               To print class loader statistics.
    --finalizerinfo         To print information on objects awaiting finalization.
    --pid <pid>             To attach to and operate on the given live process.
    --core <corefile>       To operate on the given core file.
    --exe <executable for corefile>
    --connect [<id>@]<host> To connect to a remote debug server (debugd).

    The --core and --exe options must be set together to give the core
    file, and associated executable, to operate on. They can use
    absolute or relative paths.
    The --pid option can be set to operate on a live process.
    The --connect option can be set to connect to a debug server (debugd).
    --core, --pid, and --connect are mutually exclusive.

    Examples: jhsdb jmap --pid 1234
          or  jhsdb jmap --core ./core.1234 --exe ./myexe
          or  jhsdb jmap --connect debugserver
          or  jhsdb jmap --connect id@debugserver
  • jhsdb jmap 使用示例
# jhsdb jmap --heap --pid 28562
Attaching to process ID 28562, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 13.0.2+8

using thread-local object allocation.
Garbage-First (G1) GC with 4 thread(s)

Heap Configuration: #堆内存初始化配置
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 1560281088 (1488.0MB)
   NewSize                  = 1363144 (1.2999954223632812MB)
   MaxNewSize               = 935329792 (892.0MB)
   OldSize                  = 5452592 (5.1999969482421875MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 1048576 (1.0MB)

Heap Usage: # 堆使用情况
G1 Heap: 
   regions  = 1488
   capacity = 1560281088 (1488.0MB)
   used     = 12503600 (11.924362182617188MB)
   free     = 1547777488 (1476.0756378173828MB)
   0.8013684262511551% used
G1 Young Generation: # G1新生代
Eden Space: #Eden区内存分布
   regions  = 0
   capacity = 24117248 (23.0MB)
   used     = 0 (0.0MB)
   free     = 24117248 (23.0MB)
   0.0% used
Survivor Space: #幸存区内存分布
   regions  = 0
   capacity = 0 (0.0MB)
   used     = 0 (0.0MB)
   free     = 0 (0.0MB)
   0.0% used
G1 Old Generation: # G1老年代
   regions  = 14
   capacity = 25165824 (24.0MB)
   used     = 12503600 (11.924362182617188MB)
   free     = 12662224 (12.075637817382812MB)
   49.68484242757162% used

你可能感兴趣的:(Effective,JAVA)