Serviceability Agent
DOC:
- Serviceability in HotSpot
- Serviceability Agent:An out-of-process High Level Debugger for a JVM
- JVM Memory Structure
- https://juejin.cn/post/6992108216695930917
- https://github.com/alibaba/TBJMap
前提:将项目配置(Project Structure -> Project)
- SDK 配置成 JDK 11
- Language level 配置成 11
Windows and Linux File | Settings | Build, Execution, Deployment | Compiler | Java Compiler MacOS IntelliJ IDEA | Settings | Build, Execution, Deployment | Compiler | Java Compiler 在Override compiler parameters per-module下的 conch-sa-core-v9 后面配置:
--add-modules jdk.hotspot.agent --add-exports jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.classfile=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED
在conch-sa/conch-sa-core-v9/pom.xml的 maven-compiler-plugin插件添加配置:
<configuration>
... other config
<compilerArgs>
<arg>--add-modules</arg>
<arg>jdk.hotspot.agent</arg>
<arg>--add-exports</arg>
<arg>jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED</arg>
<arg>--add-exports</arg>
<arg>jdk.hotspot.agent/sun.jvm.hotspot.classfile=ALL-UNNAMED</arg>
<arg>--add-exports</arg>
<arg>jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED</arg>
<arg>--add-exports</arg>
<arg>jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED</arg>
<arg>--add-exports</arg>
<arg>jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
在 Run/Debug Configurations 添加 Add VM options 并配置
--add-modules jdk.hotspot.agent --add-exports jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.classfile=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED --add-exports jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED
前提:将项目配置(Project Structure -> Project)
- SDK 配置成 JDK 8
- Language level 配置成 8
在conch-sa/conch-sa-core-v8/pom.xml的 maven-compiler-plugin插件添加配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin}</version>
<configuration>
<encoding>${project.encoding}</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArguments>
<!-- 要添加编译 类路径 bootclasspath: 指定sa-jdi.jar -->
<bootclasspath>
${java.home}/../lib/sa-jdi.jar${path.separator}${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar${path.separator}${java.home}/../lib/tools.jar
</bootclasspath>
</compilerArguments>
</configuration>
</plugin>