当前位置: 首页 > news >正文

聊聊jvm的direct buffer统计

本文主要研究一下jvm的direct buffer统计

spring boot metrics

jvm.memory.used

{"name": "jvm.memory.used","description": "The amount of used memory","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 137868592}],"availableTags": [{"tag": "area","values": ["heap","nonheap"]},{"tag": "id","values": ["Compressed Class Space","PS Survivor Space","PS Old Gen","Metaspace","PS Eden Space","Code Cache"]}]
}

jvm.memory.used包括heap和nonheap两大类

heap

http://localhost:8080/actuator/metrics/jvm.memory.used?tag=area:heap

{"name": "jvm.memory.used","description": "The amount of used memory","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 84724536}],"availableTags": [{"tag": "id","values": ["PS Eden Space","PS Survivor Space","PS Old Gen"]}]
}

heap的话根据具体的垃圾收集器类型有不同的区分

nonheap

http://localhost:8080/actuator/metrics/jvm.memory.used?tag=area:nonheap

{"name": "jvm.memory.used","description": "The amount of used memory","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 54874872}],"availableTags": [{"tag": "id","values": ["Metaspace","Compressed Class Space","Code Cache"]}]
}

nonheap这里包括3个,分别是Metaspace、Compressed Class Space、Code Cache

jvm.buffer.memory.used

http://localhost:8080/actuator/metrics/jvm.buffer.memory.used?tag=id:direct

{"name": "jvm.buffer.memory.used","description": "An estimate of the memory that the Java virtual machine is using for this buffer pool","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 81920}],"availableTags": [{"tag": "id","values": ["direct","mapped"]}]
}

jvm.buffer.memory.used包含了direct、mapped两大类

direct

http://localhost:8080/actuator/metrics/jvm.buffer.memory.used?tag=id:direct

{"name": "jvm.buffer.memory.used","description": "An estimate of the memory that the Java virtual machine is using for this buffer pool","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 81920}],"availableTags": []
}

mapped

http://localhost:8080/actuator/metrics/jvm.buffer.memory.used?tag=id:mapped

{"name": "jvm.buffer.memory.used","description": "An estimate of the memory that the Java virtual machine is using for this buffer pool","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 0}],"availableTags": []
}

jvm.buffer.count

http://localhost:8080/actuator/metrics/jvm.buffer.count

{"name": "jvm.buffer.count","description": "An estimate of the number of buffers in the pool","baseUnit": "buffers","measurements": [{"statistic": "VALUE","value": 10}],"availableTags": [{"tag": "id","values": ["direct","mapped"]}]
}

jvm.buffer.count分direct和mapped两大类

direct

http://localhost:8080/actuator/metrics/jvm.buffer.count?tag=id:direct

{"name": "jvm.buffer.count","description": "An estimate of the number of buffers in the pool","baseUnit": "buffers","measurements": [{"statistic": "VALUE","value": 10}],"availableTags": []
}

mapped

http://localhost:8080/actuator/metrics/jvm.buffer.count?tag=id:mapped

{"name": "jvm.buffer.count","description": "An estimate of the number of buffers in the pool","baseUnit": "buffers","measurements": [{"statistic": "VALUE","value": 0}],"availableTags": []
}

jvm.buffer.total.capacity

http://localhost:8080/actuator/metrics/jvm.buffer.total.capacity

{"name": "jvm.buffer.total.capacity","description": "An estimate of the total capacity of the buffers in this pool","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 81920}],"availableTags": [{"tag": "id","values": ["direct","mapped"]}]
}

jvm.buffer.total.capacity分direct和mapped两大类

direct

http://localhost:8080/actuator/metrics/jvm.buffer.total.capacity?tag=id:direct

{"name": "jvm.buffer.total.capacity","description": "An estimate of the total capacity of the buffers in this pool","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 81920}],"availableTags": []
}

mapped

http://localhost:8080/actuator/metrics/jvm.buffer.total.capacity?tag=id:mapped

{"name": "jvm.buffer.total.capacity","description": "An estimate of the total capacity of the buffers in this pool","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 0}],"availableTags": []
}

Native Memory Tracking

summary

jcmd 6878 VM.native_memory summary scale=MB
6878:Native Memory Tracking:Total: reserved=5625MB, committed=844MB
-                 Java Heap (reserved=4096MB, committed=577MB)(mmap: reserved=4096MB, committed=577MB)-                     Class (reserved=1066MB, committed=46MB)(classes #7027)(malloc=10MB #10535)(mmap: reserved=1056MB, committed=37MB)-                    Thread (reserved=36MB, committed=36MB)(thread #37)(stack: reserved=36MB, committed=36MB)-                      Code (reserved=246MB, committed=15MB)(malloc=2MB #3834)(mmap: reserved=244MB, committed=12MB)-                        GC (reserved=160MB, committed=148MB)(malloc=10MB #220)(mmap: reserved=150MB, committed=138MB)-                  Internal (reserved=10MB, committed=10MB)(malloc=10MB #10055)-                    Symbol (reserved=9MB, committed=9MB)(malloc=8MB #74319)(arena=2MB #1)-    Native Memory Tracking (reserved=2MB, committed=2MB)(tracking overhead=2MB)

其中Internal部分包含了jvm中使用的directBuffer的大小

示例

    public void run(String... args) throws Exception {// 分配一个256MB的直接缓冲区ByteBuffer buffer = ByteBuffer.allocateDirect(256 * 1024 * 1024);// 填充数据Random random = new Random();while (buffer.remaining() >= 4) {buffer.putInt(random.nextInt());}System.out.println("Allocated direct buffer with capacity " + buffer.capacity());}

VM.native_memory

jcmd 8077 VM.native_memory summary scale=MB
8077:Native Memory Tracking:Total: reserved=5881MB, committed=1099MB
-                 Java Heap (reserved=4096MB, committed=576MB)(mmap: reserved=4096MB, committed=576MB)-                     Class (reserved=1066MB, committed=46MB)(classes #7028)(malloc=10MB #10794)(mmap: reserved=1056MB, committed=37MB)-                    Thread (reserved=36MB, committed=36MB)(thread #37)(stack: reserved=36MB, committed=36MB)-                      Code (reserved=246MB, committed=16MB)(malloc=2MB #3889)(mmap: reserved=244MB, committed=13MB)-                        GC (reserved=160MB, committed=148MB)(malloc=10MB #220)(mmap: reserved=150MB, committed=138MB)-                  Internal (reserved=266MB, committed=266MB)(malloc=266MB #10055)-                    Symbol (reserved=9MB, committed=9MB)(malloc=8MB #74324)(arena=2MB #1)-    Native Memory Tracking (reserved=2MB, committed=2MB)(tracking overhead=2MB)

可以看到Internal部分由之前的10MB增大到了266MB

jvm.buffer.memory.used

http://localhost:8080/actuator/metrics/jvm.buffer.memory.used?tag=id:direct

{"name": "jvm.buffer.memory.used","description": "An estimate of the memory that the Java virtual machine is using for this buffer pool","baseUnit": "bytes","measurements": [{"statistic": "VALUE","value": 268476416}],"availableTags": []
}

可以看到jvm.buffer.memory.used的direct部分也变大了

小结

jvm的direct buffer可以通过springboot的jvm.buffer.memory.used?tag=id:direct来统计,也可以通过MNT的Internal部分反应出来。

doc

  • 聊聊HotSpot VM的Native Memory Tracking
  • 聊聊jvm的-XX:MaxDirectMemorySize
  • 聊聊openjdk的BufferPoolMXBean
  • 聊聊jvm的Code Cache
  • 聊聊jvm的CompressedClassSpace
  • 聊聊jvm的Stack Memory
  • 聊聊jvm的StringTable及SymbolTable
http://www.lryc.cn/news/275156.html

相关文章:

  • C/C++ 位段
  • Peter算法小课堂—树的应用
  • FineBI:简介
  • 原神单机版【完全无脑搭建】⭐纯单机⭐*稳定版*
  • 用通俗易懂的方式讲解:万字长文带你入门大模型
  • Invalid options in vue.config.js: “plugins“ is not allowed
  • 四、C语言中的数组:数组的创建与初始化
  • html5中各标签的语法格式总结以及属性值说明
  • 力扣(leetcode)第412题Fizz Buzz(Python)
  • 苦学golang半年,写了一款web服务器
  • uniapp vue2 车牌号输入组件记录
  • Unity 点击对话系统(含Demo)
  • vue接入高德地图
  • Linux的基本指令(5)
  • 华为商城秒杀时加密验证 device_data 的算法研究
  • Wrk压测发送Post请求的正确姿势
  • 【管理篇 / 登录】❀ 06. macOS下使用USB配置线登录 ❀ FortiGate 防火墙
  • linux系统shell语言的自动化交互
  • HarmonyOS ArkTS 三方库的基本使用(十六)
  • Spring boot封装rocket mq 教程
  • Java Swing手搓童年坦克大战游戏(I)
  • 【DevOps-04]】Operate阶段工具
  • 力扣2807.在链表中插入最大公约数
  • 开始刷Leetcode之前你需要知道的 - The basic is all you need
  • 【PostgreSQL】模式Schema
  • JavaScript实现的复杂功能:自动生成带水印的图片
  • 图神经网络|8.2 图卷积的计算基本方法
  • equals()与hashCode()方法详解
  • 六、基于Flask、Flasgger、marshmallow的开发调试
  • TypeScript 从入门到进阶之基础篇(三) 元组类型篇