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

观察 jvm 运行时数据区内存大小(native memory tracking)

jvm 运行时数据区

jvm 运行时数据区包括且不限于以下几个部分:

  1. 堆(heap): 用于存储对象实例和数组。堆内存的分配和释放由垃圾回收器进行管理。
  2. 方法区(method area): 用于存储类的信息、静态变量、常量等。jdk 8 后方法区位于 metaspace。
  3. 虚拟机栈(vm stack): 用于存储方法的局部变量、参数值等。
  4. 本地方法栈(native method stack): 用于存储本地方法调用的相关信息。
  5. 程序计数器(program counter): 用于记录当前线程执行的字节码指令地址。

观察 jvm 运行时数据区内存使用的命令

观察 jvm 运行时数据区内存情况可以使用 jcmd 命令:

# 需要 JVM 参数配置 -XX:NativeMemoryTracking=summary 或 -XX:NativeMemoryTracking=detail
# 使用前需要先 su 切换到 pid 的用户(top 中可看,一般 java 进程的用户是 tomcat),例如
su tomcat# 应用启动后输入
jcmd pid VM.native_memory summary
# 或
jcmd pid VM.native_memory detail# 例如
jcmd 385 VM.native_memory summary

输出内容:

image-20240611165357392

image-20240611165742991

输出的 VM.native_memory 全部内容

[tomcat@preparedocker-dep2-7f64d558f8-gfkmw default.qunar.com]$ jcmd 385 VM.native_memory summary
385:Native Memory Tracking:(Omitting categories weighting less than 1KB)Total: reserved=14696320KB, committed=13246344KB
-                 Java Heap (reserved=11534336KB, committed=11534336KB)(mmap: reserved=11534336KB, committed=11534336KB)-                     Class (reserved=1055872KB, committed=34688KB)(classes #41524)(  instance classes #39223, array classes #2301)(malloc=7296KB #139986)(mmap: reserved=1048576KB, committed=27392KB)(  Metadata:   )(    reserved=196608KB, committed=188544KB)(    used=186864KB)(    waste=1680KB =0.89%)(  Class space:)(    reserved=1048576KB, committed=27392KB)(    used=25440KB)(    waste=1952KB =7.13%)-                    Thread (reserved=574463KB, committed=245719KB)(thread #2115)(stack: reserved=568244KB, committed=239500KB)(malloc=3741KB #12726)(arena=2478KB #4229)-                      Code (reserved=262510KB, committed=170658KB)(malloc=14822KB #46616)(mmap: reserved=247688KB, committed=155836KB)-                        GC (reserved=506924KB, committed=506924KB)(malloc=45760KB #83524)(mmap: reserved=461164KB, committed=461164KB)-                  Compiler (reserved=16021KB, committed=16021KB)(malloc=15856KB #9536)(arena=165KB #5)-                  Internal (reserved=95580KB, committed=95576KB)(malloc=95540KB #150203)(mmap: reserved=40KB, committed=36KB)-                     Other (reserved=353690KB, committed=353690KB)(malloc=353690KB #1001)-                    Symbol (reserved=38658KB, committed=38658KB)(malloc=36572KB #993784)(arena=2086KB #1)-    Native Memory Tracking (reserved=24133KB, committed=24133KB)(malloc=302KB #4295)(tracking overhead=23831KB)-        Shared class space (reserved=12288KB, committed=12160KB)(mmap: reserved=12288KB, committed=12160KB)-               Arena Chunk (reserved=12414KB, committed=12414KB)(malloc=12414KB)-                   Tracing (reserved=32KB, committed=32KB)(arena=32KB #1)-                   Logging (reserved=7KB, committed=7KB)(malloc=7KB #288)-                 Arguments (reserved=4KB, committed=4KB)(malloc=4KB #138)-                    Module (reserved=4051KB, committed=4051KB)(malloc=4051KB #14643)-                 Safepoint (reserved=8KB, committed=8KB)(mmap: reserved=8KB, committed=8KB)-           Synchronization (reserved=872KB, committed=872KB)(malloc=872KB #7198)-            Serviceability (reserved=2042KB, committed=2042KB)(malloc=2042KB #35392)-                 Metaspace (reserved=198597KB, committed=190533KB)(malloc=1989KB #2357)(mmap: reserved=196608KB, committed=188544KB)-      String Deduplication (reserved=1KB, committed=1KB)(malloc=1KB #8)-           Object Monitors (reserved=3817KB, committed=3817KB)(malloc=3817KB #18790)

命令权限问题

如执行 jcmd pid VM.native_memory summary 命令后无输出,需要通过 su 切换到 pid 的用户(top 中可看,一般 java 进程的用户是 tomcat)

image-20240611202637224

http://www.lryc.cn/news/375855.html

相关文章:

  • 【论文阅读】-- 时间空间化:用于深度分类器训练的可扩展且可靠的时间旅行可视化
  • Windows系统部署本地SQL_Server指引
  • Aptos Builder Jam 亚洲首站|议程公布,无限畅想 Aptos 生态未来
  • Vue3使用component动态展示组件
  • 嵌入式中间件_2.嵌入式中间件的分类
  • 论文精读——KAN
  • 全国产城市轨道交通运营公安AI高清视频监控系统
  • python连接mysql数据库、FastAPI、mysql-connector-python
  • 【idea】解决springboot项目中遇到的问题
  • ubuntu22.04禁止自动休眠的几种方式
  • 智能网站管理系统
  • Android Service学习笔记
  • amr文件怎么转换成mp3?超好用的四种转换方法介绍!
  • 翻转数位00
  • 工具:安装R语言的R包的各种方法
  • 注意力机制和Transformer模型各部分功能解释
  • 短路是怎么形成的
  • 【ZZULIOJ】1106: 回文数(函数专题)
  • 数据库设计规范总结
  • 深度学习(九)——神经网络:最大池化的作用
  • 「前端+鸿蒙」鸿蒙应用开发-ArkTS语法说明-组件声明
  • python的subprocess 模块
  • 【Arc gis】使用DEM提取流域范围
  • 大模型技术工程师:抓住时代机遇,成为行业精英_
  • 孟德尔随机化R包:TwoSampleMR和MR-PRESSO安装
  • 6月18日 Qtday4
  • Vue3模拟国足18强赛抽签
  • mesa编译器nir信息储存问题
  • windows下mysql设置开机自启动
  • L2-002 链表去重(C++)