HotSpot NMT介绍

Overview

The Native Memory Tracking (NMT) is a Java Hotspot VM feature that tracks internal memory usage for a HotSpot JVM. You can access NMT data using jcmd utility. NMT in this release does not track third party native code memory allocations and JDK class libraries. Also, this release does not include NMT MBean in HotSpot for JMC.

Key Features

  • Native Memory Tracking has the following features and when used with jcmd can track memory usage at differnet levels.

  • NMT for Hotspot VM is turned off by default. Turn this feature on using JVM command line option. See the Native Memory Tracking command man page.

  • Memory tracking data can be accessed using jcmd utility. See use jcmd to access NMT data.

  • Generate summary and detail reports.

  • Establish an early baseline for later comparison.

  • Request a memory usage report at JVM exit with the JVM command line option. See NMT at VM exit.

  • NMT can be shutdown using jcmd utility, but can not start/restart using jcmd.

How to Use Native Memory Tracking
First enable NMT and then use jcmd to access the data collected thus far.

Enable NMT
Enable NMT using the following command line. Note that enabling this will cause 5-10% performance overhead.

-XX:NativeMemoryTracking=[off | summary | detail]

offNMT is turned off by default.
summaryOnly collect memory usage aggregated by subsystem.
detailCollect memory usage by individual call sites.

Use jcmd to Access NMT Data
Use jcmd to dump the data collected and optionally compare it to the last baseline.

jcmd VM.native_memory [summary | detail | baseline | summary.diff | detail.diff | shutdown] [scale= KB | MB | GB]

summaryPrint a summary aggregated by category.
detail
  • Print memory usage aggregated by category
  • Print virtual memory map
  • Print memory usage aggregated by call site
baselineCreate a new memory usage snapshot to diff against.
summary.diffPrint a new summary report against the last baseline.
detail.diffPrint a new detail report against the last baseline.
shutdownShutdown NMT.

NMT at VM Exit
Use the following VM diagnostic command line option to obtain last memory usage data at VM exit when Native Memory Tracking is enabled. The level of detail is based on tracking level.

-XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics

扩展
java8给HotSpot VM引入了Native Memory Tracking (NMT)特性
例子

-XX:NativeMemoryTracking=summary
/zxjdk-8u212-linux-x64/bin # jcmd 413  VM.native_memory summary scale=MB
413:

Native Memory Tracking:

Total: reserved=1821MB, committed=496MB
-                 Java Heap (reserved=300MB, committed=200MB)
                            (mmap: reserved=300MB, committed=200MB)

-                     Class (reserved=1092MB, committed=76MB)
                            (classes #14152)
                            (malloc=2MB #26102)
                            (mmap: reserved=1090MB, committed=74MB)

-                    Thread (reserved=130MB, committed=130MB)
                            (thread #130)
                            (stack: reserved=129MB, committed=129MB)

-                      Code (reserved=251MB, committed=42MB)
                            (malloc=7MB #10703)
                            (mmap: reserved=244MB, committed=35MB)

-                        GC (reserved=1MB, committed=1MB)
                            (mmap: reserved=1MB, committed=1MB)

-                  Compiler (reserved=1MB, committed=1MB)

-                  Internal (reserved=25MB, committed=25MB)
                            (malloc=25MB #19980)

-                    Symbol (reserved=18MB, committed=18MB)
                            (malloc=16MB #167642)
                            (arena=2MB #1)

-    Native Memory Tracking (reserved=3MB, committed=3MB)
                            (tracking overhead=3MB)

其中reserved表示应用可用的内存大小,committed表示应用正在使用的内存大小

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
为什么要学JVM1、一切JAVA代码都运行在JVM之上,只有深入理解虚拟机才能写出更强大的代码,解决更深层次的问题。2、JVM是迈向高级工程师、架构师的必备技能,也是高薪、高职位的不二选择。3、同时,JVM又是各大软件公司笔试、面试的重中之重,据统计,头部的30家互利网公司,均将JVM作为笔试面试的内容之一。4、JVM内容庞大、并且复杂难学,通过视频学习是最快速的学习手段。课程介绍本课程包含11个大章节,总计102课时,无论是笔试、面试,还是日常工作,可以让您游刃有余。第1章 基础入门,从JVM是什么开始讲起,理解JDK、JRE、JVM的关系,java的编译流程和执行流程,让您轻松入门。第2章 字节码文件,深入剖析字节码文件的全部组成结构,以及javap和jbe可视化反解析工具的使用。第3章 类的加载、解释、编译,本章节带你深入理解类加载器的分类、范围、双亲委托策略,自己手写类加载器,理解字节码解释器、即时编译器、混合模式、热点代码检测、分层编译等核心知识。第4章 内存模型,本章节涵盖JVM内存模型的全部内容,程序计数器、虚拟机栈、本地方法栈、方法区、永久代、元空间等全部内容。第5章 对象模型,本章节带你深入理解对象的创建过程、内存分配的方法、让你不再稀里糊涂。第6章 GC基础,本章节是垃圾回收的入门章节,带你了解GC回收的标准是什么,什么是可达性分析、安全点、安全区,四种引用类型的使用和区别等等。第7章 GC算法与收集器,本章节是垃圾回收的重点,掌握各种垃圾回收算法,分代收集策略,7种垃圾回收器的原理和使用,垃圾回收器的组合及分代收集等。第8章 GC日志详解,各种垃圾回收器的日志都是不同的,怎么样读懂各种垃圾回收日志就是本章节的内容。第9章 性能监控与故障排除,本章节实战学习jcmd、jmx、jconsul、jvisualvm、JMC、jps、jstatd、jmap、jstack、jinfo、jprofile、jhat总计12种性能监控和故障排查工具的使用。第10章 阿里巴巴Arthas在线诊断工具,这是一个特别小惊喜,教您怎样使用当前最火热的arthas调优工具,在线诊断各种JVM问题。第11章 故障排除,本章会使用实际案例讲解单点故障、高并发和垃圾回收导致的CPU过高的问题,怎样排查和解决它们。课程资料课程附带配套项目源码2个159页高清PDF理论篇课件1份89页高清PDF实战篇课件1份Unsafe源码PDF课件1份class_stats字段说明PDF文件1份jcmd Thread.print解析说明文件1份JProfiler内存工具说明文件1份字节码可视化解析工具1份GC日志可视化工具1份命令行工具cmder 1份学习方法理论篇部分推荐每天学习2课时,可以在公交地铁上用手机进行学习。实战篇部分推荐对照视频,使用配套源码,一边练习一遍学习。课程内容较多,不要一次性学太多,而是要循序渐进,坚持学习。      

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值