Jmap 查看Heap信息

准备代码:

public class GarbageRecycle {

    public static void main(String[] args) throws InterruptedException {
        System.out.println("1.................");
        Thread.sleep(30000);
        byte[] array = new byte[20 * 1024 * 1024];
        System.out.println("2.................");
        Thread.sleep(30000);
        array = null;
        System.gc();
        System.out.println("3.................");
        Thread.sleep(3000000);
    }
}

jps查看进程信息

查看pid:23280 堆使用信息:jhsdb jmap --heap --pid 23280
注:jdk8之前的命令是(jmap -heap 23280)

此时 G1 Heap used 为26m

Attaching to process ID 23280, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 11.0.11+9-LTS-194

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

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 8533311488 (8138.0MB)
   NewSize                  = 1363144 (1.2999954223632812MB)
   MaxNewSize               = 5119148032 (4882.0MB)
   OldSize                  = 5452592 (5.1999969482421875MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 2097152 (2.0MB)

Heap Usage:
G1 Heap:
   regions  = 4069
   capacity = 8533311488 (8138.0MB)
   used     = 27262976 (26.0MB)
   free     = 8506048512 (8112.0MB)
   0.3194888178913738% used
G1 Young Generation:
Eden Space:
   regions  = 3
   capacity = 27262976 (26.0MB)
   used     = 6291456 (6.0MB)
   free     = 20971520 (20.0MB)
   23.076923076923077% used
Survivor Space:
   regions  = 0
   capacity = 0 (0.0MB)
   used     = 0 (0.0MB)
   free     = 0 (0.0MB)
   0.0% used
G1 Old Generation:
   regions  = 11
   capacity = 507510784 (484.0MB)
   used     = 20971520 (20.0MB)
   free     = 486539264 (464.0MB)
   4.132231404958677% used


程序打印3.................之后再次查询:G1 Heap used 仅为1m

F:\project\javaBase>jhsdb jmap --heap --pid 23280
Attaching to process ID 23280, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 11.0.11+9-LTS-194

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

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 8533311488 (8138.0MB)
   NewSize                  = 1363144 (1.2999954223632812MB)
   MaxNewSize               = 5119148032 (4882.0MB)
   OldSize                  = 5452592 (5.1999969482421875MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 2097152 (2.0MB)

Heap Usage:
G1 Heap:
   regions  = 4069
   capacity = 8533311488 (8138.0MB)
   used     = 1470520 (1.4023971557617188MB)
   free     = 8531840968 (8136.597602844238MB)
   0.017232700365712936% used
G1 Young Generation:
Eden Space:
   regions  = 0
   capacity = 8388608 (8.0MB)
   used     = 0 (0.0MB)
   free     = 8388608 (8.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:
   regions  = 3
   capacity = 12582912 (12.0MB)
   used     = 1470520 (1.4023971557617188MB)
   free     = 11112392 (10.597602844238281MB)
   11.68664296468099% used

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值