jmap - Memory Map

先说明一个linux下的命令 jps 和 jmap 

  jps 用于 列出所有java相关线程的pid等信息,如:

[root@myjrjapp-100 ~]# jps
23178 Jps
20289 Bootstrap

其中,“20289 Bootstrap”是指系统中运行的tomcat进程号和进程名。

 

     jmap 是一个可以输出所有内存中对象的工具,甚至可以将 VM 中的 heap ,以二进制输出成文本。

jmap -dump:format=b,file=f1 3024 可以将 3024 进程的内存 heap 输出出来到 f1 文件里。 它可以打印出某个 java进程(使用 pid )内存内的,所有  对象  的情况(如:产生那些对象,及其数量)

如: jmap pid    打印内存使用的摘要信息

分析方法1:

    以上两个命令可以结合起来用,例如:

[root@myjrjapp-100 ~]# jps
23178 Jps
20289 Bootstrap


[root@myjrjapp-100 ~]# jmap 20289 
Attaching to process ID 20289, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 10.0-b19

using thread-local object allocation.
Parallel GC with 8 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 1073741824 (1024.0MB)
   NewSize          = 1048576 (1.0MB)
   MaxNewSize       = 4294901760 (4095.9375MB)
   OldSize          = 4194304 (4.0MB)
   NewRatio         = 8
   SurvivorRatio    = 8
   PermSize         = 134217728 (128.0MB)
   MaxPermSize      = 268435456 (256.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 118358016 (112.875MB)
   used     = 38070328 (36.30669403076172MB)
   free     = 80287688 (76.56830596923828MB)
   32.165398919833194% used
From Space:
   capacity = 458752 (0.4375MB)
   used     = 155664 (0.1484527587890625MB)
   free     = 303088 (0.2890472412109375MB)
   33.932059151785715% used
To Space:
   capacity = 458752 (0.4375MB)
   used     = 0 (0.0MB)
   free     = 458752 (0.4375MB)
   0.0% used
PS Old Generation
   capacity = 954466304 (910.25MB)
   used     = 72784624 (69.41282653808594MB)
   free     = 881681680 (840.8371734619141MB)
   7.625688166776813% used
PS Perm Generation
   capacity = 134217728 (128.0MB)
   used     = 38192248 (36.42296600341797MB)
   free     = 96025480 (91.57703399658203MB)
   28.455442190170288% used
[root@myjrjapp-100 ~]# 


分析方法2:

使用jmap命令dump内存出来 :
jmap -dump:live,format=b,file=heap.bin 8023

   之后会在当前目录创建一个”heap.bin”文件,会有好几百M大小。可以把此文件进行压缩,然后再传到其他windows机器中进行结果分析。

[root@openAS-main ~]# gzip heap.bin


jmap命令详细使用:

SYNOPSIS

jmap [ option ] pid jmap [ option ] executable core jmap [ option ] [server-id@]remote-hostname-or-IP

PARAMETERS

option
Options are mutually exclusive. Option, if used, should follow immediately after the command name.

 

pid
process id for which the memory map is to be printed. The process must be a Java process. To get a list of Java processes running on a machine,  jps may be used.
executable
Java executable from which the core dump was produced.
core
core file for which the memory map is to be printed.
remote-hostname-or-IP
remote debug server's (see  jsadebugd) hostname or IP address.
server-id
optional unique id, if multiple debug servers are running on the same remote host.

DESCRIPTION

jmap prints shared object memory maps or heap memory details of a given process or core file or a remote debug server.

NOTE - This utility is unsupported and may or may not be available in future versions of the J2SE SDK.
jmap is not currently available on Windows platforms or on the Linux Itanium platform.

OPTIONS

<no option> 
When no option is used jmap prints shared object mappings. For each shared object loaded in the target VM, start address, the size of the mapping, and the full path of the shared object file are printed. This is similar to the Solaris  pmap utility.
-heap
Prints a heap summary. GC algorithm used, heap configuration and generation wise heap usage are printed.
-histo
Prints a histogram of the heap. For each Java class, number of objects, memory size in bytes, and fully qualified class names are printed. VM internal class names are printed with '*' prefix.
-permstat
Prints class loader wise statistics of permanent generation of Java heap. For each class loader, its name, liveness, address, parent class loader, and the number and size of classes it has loaded are printed.
-h
Prints a help message.

-help
Prints a help message.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值