MAT内存分析工具-独立版安装

 一、背景

在java程序运行中发生OOM的时候,我们可以使用强大的内存分析工具MAT进行问题跟踪,但由于习惯了使用idea开发,再为了MAT下载个eclipse太麻烦,所以安装MAT独立版。

二、安装

下载地址:https://eclipse.org/mat/downloads.php,如下



选择自己系统相应的版本下载,下载完得到一个zip文件,笔者这里使用的是Mac OSX (Mac/Cocoa x86_64),解压后得到mat文件

如果这里双击打开没问题,则可以开始正常使用了;如果双击提示异常,那么继续往下看,提示如下

 

按照提示路径进入日志文件,异常信息:
java.lang.IllegalStateException: The platform metadata area could not be 
written: /private/var/folders/d_/9dsdb3jd0bbg2lq9kvhdlvz00000gn/T/AppTranslocation/13816EDC-675E-4D44-9337-C5A7658C046A/d/mat.app/Contents/MacOS/workspace/
.metadata.  By default the platform writes its content
under the current working directory when the platform is launched.  Use the -data parameter to
specify a different content area for the platform.
        at org.eclipse.core.internal.runtime.DataArea.assertLocationInitialized(DataArea.java:61)
        at org.eclipse.core.internal.runtime.DataArea.getStateLocation(DataArea.java:129)
        at org.eclipse.core.internal.preferences.InstancePreferences.getBaseLocation(InstancePreferences.java:44)
        at org.eclipse.core.internal.preferences.InstancePreferences.initializeChildren(InstancePreferences.java:199)
        at org.eclipse.core.internal.preferences.InstancePreferences.<init>(InstancePreferences.java:59)
        at org.eclipse.core.internal.preferences.InstancePreferences.internalCreate(InstancePreferences.java:209)
        at org.eclipse.core.internal.preferences.EclipsePreferences.create(EclipsePreferences.java:391)
        at org.eclipse.core.internal.preferences.EclipsePreferences.create(EclipsePreferences.java:379)
        at org.eclipse.core.internal.preferences.PreferencesService.createNode(PreferencesService.java:389)
        at org.eclipse.core.internal.preferences.RootPreferences.getChild(RootPreferences.java:63)
        at org.eclipse.core.internal.preferences.RootPreferences.getNode(RootPreferences.java:101)
        at org.eclipse.core.internal.preferences.RootPreferences.node(RootPreferences.java:90)
        at org.eclipse.core.internal.preferences.AbstractScope.getNode(AbstractScope.java:38)
        at org.eclipse.core.runtime.preferences.InstanceScope.getNode(InstanceScope.java:80)
        at org.eclipse.ui.preferences.ScopedPreferenceStore.getStorePreferences(ScopedPreferenceStore.java:229)
        at org.eclipse.ui.preferences.ScopedPreferenceStore.<init>(ScopedPreferenceStore.java:133)
        at org.eclipse.ui.plugin.AbstractUIPlugin.getPreferenceStore(AbstractUIPlugin.java:288)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:620)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
        at org.eclipse.mat.ui.rcp.Application.start(Application.java:26)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1515)

这是eclipse的一个bug,记录地址:https://bugs.eclipse.org/bugs/show_bug.cgi?id=339647#c5

解决办法(以mac为例)

右键mat显示包内容,进入Contents->MacOS下面,会有一个MemoryAnalyzer的命令。

打开终端,进入此路径找到MemoryAnalyzer,运行

./MemoryAnalyzer -data ./dump

成功启动,当然敲全路径启动也是可以的,dump文件名可以自定义。

猜你喜欢

转载自mahl1990.iteye.com/blog/2410197
今日推荐