前言
MAT作为开发者分析堆栈快照信息的常用工具,本文介绍了在MBP M1中安装指南。
下载
首先去https://www.eclipse.org/mat/downloads.php下载MAT的安装包
异常
安装jdk11
在https://www.azul.com/downloads/?package=jdk#download-openjdk下载jdk11
验证
duansg@DuansiguodeMacBook-Pro zulu-8.jdk % java -version
openjdk version "11.0.16.1" 2022-07-19 LTS
OpenJDK Runtime Environment Zulu11.58+23-CA (build 11.0.16.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.58+23-CA (build 11.0.16.1+1-LTS, mixed mode)
环境配置
# 编辑配置文件
vim ~/.bash_profile
# 配置JDK路径
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
# 设置默认JDK版本
export JAVA_HOME=$JAVA_11_HOME
# 配置alias命令可以动态切换JDK版本
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk11="export JAVA_HOME=$JAVA_11_HOME"
alias jdk17="export JAVA_HOME=$JAVA_17_HOME"
export JAVA_HOME
export PATH
export CLASSPATH
# maven配置
export MAVEN_HOME=/Users/itzhuzhu/Desktop/Java/maven/apache-maven-3.8.4
export PATH=$PATH:$MAVEN_HOME/bin
source ~/.bash_profile
验证环境
duansg@DuansiguodeMacBook-Pro JavaVirtualMachines % java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (Zulu 8.58.0.13-CA-macos-aarch64) (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (Zulu 8.58.0.13-CA-macos-aarch64) (build 25.312-b07, mixed mode)
duansg@DuansiguodeMacBook-Pro JavaVirtualMachines % jdk11
duansg@DuansiguodeMacBook-Pro JavaVirtualMachines % java -version
openjdk version "11.0.16.1" 2022-07-19 LTS
OpenJDK Runtime Environment Zulu11.58+23-CA (build 11.0.16.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.58+23-CA (build 11.0.16.1+1-LTS, mixed mode)
duansg@DuansiguodeMacBook-Pro JavaVirtualMachines % jdk8
duansg@DuansiguodeMacBook-Pro JavaVirtualMachines % java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (Zulu 8.58.0.13-CA-macos-aarch64) (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (Zulu 8.58.0.13-CA-macos-aarch64) (build 25.312-b07, mixed mode)
duansg@DuansiguodeMacBook-Pro JavaVirtualMachines %
MAT配置修改
在MAT包的目录下找到MemoryAnalyzer.ini,编辑MemoryAnalyzer.ini
-vm
/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin
-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
--launcher.library
../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx_1.2.400.v20211117-0650
-vmargs
-Xmx1024m
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XstartOnFirstThread