课程目录
- JVM介绍
- HotSpot虚拟机讲解
- 垃圾收集方式详解
- 垃圾收集算法详解
- 垃圾收集器详解
- 分代垃圾收集机制详解
- 新生代讲解
- 老年代讲解
- G1收集器分析与实例
- 常见且重要虚拟机参数示例
- 栈
- 方法区
- 线程共享内存区
- 根搜索算法
- Serial收集器
- ParNew收集器
- 类加载机制详解
- 类加载的双亲委托机制
- 字节码文件生成与分析
- 魔数
- 常量池与方法表
- 各种指令详解
- 锁详解
- 线程安全
- 偏向锁、自旋锁与轻量级锁
- JIT编译器
- GC日志生成与分析
- 虚拟机监控工具详解
- jConsole使用方式详解
- 何为逃逸与逃逸分析
- 方法内联
- 虚拟机内存模型详解
工具
JConsole
Last login: Wed Jun 19 23:39:17 on ttys001
➜ ~ jconsole
点击“连接”之后出现了错误,安全连接失败。。。
谷歌后发现都说要添加一个JVM参数-Djava.rmi.server.hostname=localhost,但是实际测试没有效果,后来在oracle论坛上找到解决方案,地址https://community.oracle.com/thread/4115805,需要在~/.bash_profile中添加如下环境变量,这样在执行jconsole命令的时候会自动添加该JVM参数。关于JAVA_TOOL_OPTIONS的介绍在下面的网页
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html
export JAVA_TOOL_OPTIONS="-Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9595"
➜ bin vi ~/.bash_profile
➜ bin source ~/.bash_profile
➜ bin jconsole
Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9595
最终成功打开页面
2. jvisualvm
jvisualvm在mac下的oracle jdk12无法打开,表现如下
➜ Commands jvisualvm
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home/bin/jvisualvm" (-1)
在Stack Overflow找到如下答案,意思是说从Oracle JDK9开始jvisualvm成为一个独立的开源项目而不再包含其中
For JDK 9 users
Starting with JDK 9, Visual VM will not be included with Oracle JDK. Developers who would like to use Visual VM with Oracle JDK 9 or later can get it from the Visual VM open source project site.
这是该项目的链接: https://visualvm.github.io/
Starting from Oracle JDK 9, Java VisualVM has moved to the GraalVM, an innovative, high-performance polyglot VM developed at Oracle Labs. Similar to Java VisualVM, Graal VisualVM is a stable tool built on top of the VisualVM and tested with the concrete GraalVM release.
Mac下安装地址https://github.com/visualvm/visualvm.src/releases/download/1.4.3/VisualVM_143.dmg