JVM调优(ubuntu系统下)

1、使用MAT查看服务是因为什么代码导致的停服(例如OOM)

不太好验证,写了一个死循环放在接口里,然后调用接口3次,机器直接挂掉了,没有任何的hprof文件产生

调用接口

机器直接挂了。但是没有看到hprof文件,

这样怎么办呢,才能验证我的这个学习需求呢? 

这段代码不太适合验证OOM,只是频繁往磁盘记录log造成IO交互频率高,CPU倒是挺高的,但是内存一直涨不上去。

所以换用如下代码:

private static final Integer K = 1024;
    /**
     * 死循环,验证JVM调优
     * @return
     */
    @GetMapping(value = "/deadLoop")
    public void deadLoop(){
        int size = K * K * 8;
        List<byte[]> list = new ArrayList<>();
        for (int i = 0; i < K; i++) {
            log.info("deadLoop"+i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            list.add(new byte[size]);
        }

    }

往内存中写入大字节内容,内存就会溢出。

调用接口,发现没生成hprof文件,网上找了办法,启动脚本startup.sh需要这样改:

nohup java -jar -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/lighthouse/hmblogs hmblogs.jar >nohup.log 2>&1 &

开启内存泄漏时输出堆栈信息:

-XX:+HeapDumpOnOutOfMemoryError

指定堆栈信息输出的路径:

-XX:HeapDumpPath=/home/tempadmin/hwzt-third-party

调用接口后,查看生成了hprof文件,800多M的文件:

虽然获得了hprof文件,在windows系统下也可以在MAT工具中获取OOM相应信息(参考JVM调优(Window下)-CSDN博客),

也可以通过执行如下命令,生成hprof文件:

jmap -dump:format=b,file=/home/lighthouse/hemingdump.hprof 3878

其中3878为java服务的pid

但是文件这么大,而且还是在云主机里,每次都下载到本地个人电脑里,网速慢下载花时间,如果1次还好,但是如果要多次分析内存溢出情况,就会很麻烦。

试试看能不能在ubuntu系统上安装一个MAT,在ubuntu里使用MAT生成内存溢出情况页面包,下载该页面包到个人本地电脑里面点开页面查看具体内存溢出情况。

下载linux版本的mat,Eclipse Memory Analyzer Open Source Project | The Eclipse Foundation

到这里下载,我下载的是1.0.0的版本,MemoryAnalyzer-1.0.0.20100520-linux.gtk.x86_64.zip

上传到云主机后,使用unzip MemoryAnalyzer-1.0.0.20100520-linux.gtk.x86_64.zip命令解压后,

进入mat目录,执行如下命令:

sh ParseHeapDump.sh /home/lighthouse/hmblogs/java_pid3878.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components

报错了,执行该命令,显示的所有信息如下:

: not foundmp.sh: 9: 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.osgi.internal.baseadaptor.BaseStorage (file:/home/lighthouse/mat/plugins/org.eclipse.osgi_3.5.0.v20090520.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.baseadaptor.BaseStorage
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
!SESSION 2024-02-18 11:12:25.834 -----------------------------------------------
eclipse.buildId=unknown
java.version=11.0.21
java.vendor=Ubuntu
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -application org.eclipse.mat.api.parse /home/lighthouse/hemingdump.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components
Command-line arguments:  -os linux -ws gtk -arch x86_64 -consolelog -application org.eclipse.mat.api.parse /home/lighthouse/hemingdump.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components

!ENTRY org.eclipse.equinox.common 4 0 2024-02-18 11:12:26.240
!MESSAGE 
!STACK 0
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:330)

!ENTRY org.eclipse.update.configurator 4 0 2024-02-18 11:12:26.243
!MESSAGE 
!STACK 0
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.4,CDC-1.0/Foundation-1.0,J2SE-1.3
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:330)

!ENTRY org.eclipse.core.runtime 4 0 2024-02-18 11:12:26.246
!MESSAGE 
!STACK 0
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,J2SE-1.3
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:330)

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:12:26.251
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.common_3.5.0.v20090520-1800.jar/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:12:26.251
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.update.configurator_3.3.0.v20090312.jar/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:12:26.252
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.core.runtime_3.5.0.v20090525.jar/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:12:26.255
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

!ENTRY org.eclipse.osgi 2 0 2024-02-18 11:12:26.270
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:12:26.271
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.core.runtime_3.5.0.v20090525.jar/ was not resolved.
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.271
!MESSAGE Missing required bundle org.eclipse.equinox.preferences_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.271
!MESSAGE Missing required bundle org.eclipse.core.jobs_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.272
!MESSAGE Missing required bundle org.eclipse.equinox.app_[1.0.0,2.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.272
!MESSAGE Missing required bundle org.eclipse.equinox.registry_[3.4.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.273
!MESSAGE Missing required bundle org.eclipse.core.contenttype_[3.3.0,4.0.0).
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:12:26.273
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.update.configurator_3.3.0.v20090312.jar/ was not resolved.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.273
!MESSAGE Missing imported package org.w3c.dom_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.274
!MESSAGE Missing imported package javax.xml.parsers_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.274
!MESSAGE Missing imported package org.xml.sax_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.275
!MESSAGE Missing imported package org.xml.sax.helpers_0.0.0.

!ENTRY org.eclipse.osgi 2 0 2024-02-18 11:12:26.277
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:12:26.277
!MESSAGE Bundle org.eclipse.equinox.common_3.5.0.v20090520-1800 [1] was not resolved.
!SUBENTRY 2 org.eclipse.equinox.common 2 0 2024-02-18 11:12:26.278
!MESSAGE Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:12:26.278
!MESSAGE Bundle org.eclipse.update.configurator_3.3.0.v20090312 [2] was not resolved.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.278
!MESSAGE Missing required bundle org.eclipse.equinox.common_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.279
!MESSAGE Missing imported package javax.xml.parsers_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.279
!MESSAGE Missing imported package org.w3c.dom_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.280
!MESSAGE Missing imported package org.xml.sax_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:12:26.280
!MESSAGE Missing imported package org.xml.sax.helpers_0.0.0.
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:12:26.280
!MESSAGE Bundle org.eclipse.core.runtime_3.5.0.v20090525 [3] was not resolved.
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.280
!MESSAGE Missing required bundle org.eclipse.equinox.common_[3.5.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.281
!MESSAGE Missing required bundle org.eclipse.core.jobs_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.281
!MESSAGE Missing required bundle org.eclipse.equinox.registry_[3.4.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.281
!MESSAGE Missing required bundle org.eclipse.equinox.preferences_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.282
!MESSAGE Missing required bundle org.eclipse.core.contenttype_[3.3.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.282
!MESSAGE Missing optionally required bundle org.eclipse.core.runtime.compatibility.auth_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.283
!MESSAGE Missing required bundle org.eclipse.equinox.app_[1.0.0,2.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:12:26.284
!MESSAGE Missing imported package org.eclipse.core.internal.runtime.auth_0.0.0.
lighthouse@VM-8-10-ubuntu:~/mat$ sh ParseHeapDump.sh /home/lighthouse/hmblogs/java_pid3878.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components
: not foundmp.sh: 9: 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.osgi.internal.baseadaptor.BaseStorage (file:/home/lighthouse/mat/plugins/org.eclipse.osgi_3.5.0.v20090520.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.baseadaptor.BaseStorage
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
!SESSION 2024-02-18 11:18:11.445 -----------------------------------------------
eclipse.buildId=unknown
java.version=11.0.21
java.vendor=Ubuntu
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -application org.eclipse.mat.api.parse /home/lighthouse/hmblogs/java_pid3878.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components
Command-line arguments:  -os linux -ws gtk -arch x86_64 -consolelog -application org.eclipse.mat.api.parse /home/lighthouse/hmblogs/java_pid3878.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components

!ENTRY org.eclipse.equinox.common 4 0 2024-02-18 11:18:11.898
!MESSAGE 
!STACK 0
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:330)

!ENTRY org.eclipse.update.configurator 4 0 2024-02-18 11:18:11.901
!MESSAGE 
!STACK 0
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: J2SE-1.4,CDC-1.0/Foundation-1.0,J2SE-1.3
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:330)

!ENTRY org.eclipse.core.runtime 4 0 2024-02-18 11:18:11.903
!MESSAGE 
!STACK 0
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,J2SE-1.3
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:330)

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:18:11.909
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.common_3.5.0.v20090520-1800.jar/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:18:11.910
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.update.configurator_3.3.0.v20090312.jar/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:18:11.910
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.core.runtime_3.5.0.v20090525.jar/ was not resolved.

!ENTRY org.eclipse.osgi 4 0 2024-02-18 11:18:11.913
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

!ENTRY org.eclipse.osgi 2 0 2024-02-18 11:18:11.920
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:18:11.921
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.core.runtime_3.5.0.v20090525.jar/ was not resolved.
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.921
!MESSAGE Missing required bundle org.eclipse.equinox.preferences_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.923
!MESSAGE Missing required bundle org.eclipse.core.jobs_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.923
!MESSAGE Missing required bundle org.eclipse.equinox.app_[1.0.0,2.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.924
!MESSAGE Missing required bundle org.eclipse.equinox.registry_[3.4.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.924
!MESSAGE Missing required bundle org.eclipse.core.contenttype_[3.3.0,4.0.0).
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:18:11.925
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.update.configurator_3.3.0.v20090312.jar/ was not resolved.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.925
!MESSAGE Missing imported package org.w3c.dom_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.925
!MESSAGE Missing imported package javax.xml.parsers_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.926
!MESSAGE Missing imported package org.xml.sax_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.927
!MESSAGE Missing imported package org.xml.sax.helpers_0.0.0.

!ENTRY org.eclipse.osgi 2 0 2024-02-18 11:18:11.929
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:18:11.935
!MESSAGE Bundle org.eclipse.equinox.common_3.5.0.v20090520-1800 [1] was not resolved.
!SUBENTRY 2 org.eclipse.equinox.common 2 0 2024-02-18 11:18:11.936
!MESSAGE Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:18:11.936
!MESSAGE Bundle org.eclipse.update.configurator_3.3.0.v20090312 [2] was not resolved.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.937
!MESSAGE Missing required bundle org.eclipse.equinox.common_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.937
!MESSAGE Missing imported package javax.xml.parsers_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.938
!MESSAGE Missing imported package org.w3c.dom_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.938
!MESSAGE Missing imported package org.xml.sax_0.0.0.
!SUBENTRY 2 org.eclipse.update.configurator 2 0 2024-02-18 11:18:11.939
!MESSAGE Missing imported package org.xml.sax.helpers_0.0.0.
!SUBENTRY 1 org.eclipse.osgi 2 0 2024-02-18 11:18:11.939
!MESSAGE Bundle org.eclipse.core.runtime_3.5.0.v20090525 [3] was not resolved.
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.940
!MESSAGE Missing required bundle org.eclipse.equinox.common_[3.5.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.940
!MESSAGE Missing required bundle org.eclipse.core.jobs_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.941
!MESSAGE Missing required bundle org.eclipse.equinox.registry_[3.4.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.941
!MESSAGE Missing required bundle org.eclipse.equinox.preferences_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.942
!MESSAGE Missing required bundle org.eclipse.core.contenttype_[3.3.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.942
!MESSAGE Missing optionally required bundle org.eclipse.core.runtime.compatibility.auth_[3.2.0,4.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.943
!MESSAGE Missing required bundle org.eclipse.equinox.app_[1.0.0,2.0.0).
!SUBENTRY 2 org.eclipse.core.runtime 2 0 2024-02-18 11:18:11.943
!MESSAGE Missing imported package org.eclipse.core.internal.runtime.auth_0.0.0.

无意中看到了java 版本可能引起的问题,查看了一下java -version,发现是11,之前使用elastic search改成了11,现在改成java 8.

重新执行

sh ParseHeapDump.sh /home/lighthouse/hmblogs/java_pid3878.hprof org.eclipse.mat.api:suspects

报另外的错了,错误如下:

: not foundmp.sh: 9: 
Task: Parsing java_pid3878.hprof
[Task: Parsing /home/lighthouse/hmblogs/java_pid3878.hprof
[
Subtask: Scanning /home/lighthouse/hmblogs/java_pid3878.hprof
[....................
[INFO] Wrote threads call stacks to /home/lighthouse/hmblogs/java_pid3878.threads
[....................
[INFO] Heap /home/lighthouse/hmblogs/java_pid3878.hprof contains 458,084 objects
[....................
Subtask: Extracting objects from /home/lighthouse/hmblogs/java_pid3878.hprof
[................................................................................Task: Removing unreachable objects
[
Subtask: Searching for unreachable objects
[
Subtask: Calculate Retained Size
[.
Subtask: Re-indexing objects
[..
Subtask: Re-indexing classes
[...
Subtask: Writing /home/lighthouse/hmblogs/java_pid3878.idx.index
[....
Subtask: Writing /home/lighthouse/hmblogs/java_pid3878.o2c.index
[.....
Subtask: Writing /home/lighthouse/hmblogs/java_pid3878.a2s.index
[......
Subtask: Re-indexing outbound index
[.......
Subtask: Writing /home/lighthouse/hmblogs/java_pid3878.inbound.index
[........
Subtask: Writing /home/lighthouse/hmblogs/java_pid3878.outbound.index
[.........
Subtask: Writing /home/lighthouse/hmblogs/java_pid3878.o2hprof.index
[.........Task: Calculating Dominator Tree
[
Subtask: Dominator Tree calculation
[
Subtask: Depth-first search
[....................
Subtask: Computing dominators
[...............................................
Subtask: Calculate retained sizes
[.............................................................
Subtask: Create dominators index file
[..................................................................................]

Subtask: Test 'Heap Dump Overview' of section 'System Overview'
[
Subtask: Test 'System Properties' of section 'System Overview'
[
Subtask: Extracting Key Value Pairs...
[
Subtask: Test 'Thread Overview' of section 'System Overview'
[
Subtask: Searching Threads...
[
Subtask: Test 'Top Consumers' of section 'System Overview'
[
Subtask: Creating histogram
[
Subtask: Grouping by package
[
Subtask: Test 'Biggest Objects (Overview)' of section 'Top Consumers'
[
Subtask: Test 'Biggest Objects' of section 'Top Consumers'
[
Subtask: Test 'Biggest Top-Level Dominator Classes (Overview)' of section 'Top Consumers'
[
Subtask: Test 'Biggest Top-Level Dominator Classes' of section 'Top Consumers'
[
Subtask: Test 'Biggest Top-Level Dominator Class Loaders (Overview)' of section 'Top Consumers'
[
Subtask: Test 'Biggest Top-Level Dominator Class Loaders' of section 'Top Consumers'
[
Subtask: Test 'Biggest Top-Level Dominator Packages' of section 'Top Consumers'
[
Subtask: Test 'Class Histogram' of section 'System Overview'
[
Subtask: Test 'Leaks' of section 'Leak Suspects'
[
Subtask: Finding problem suspects
[
Subtask: Preparing results
[
Subtask: Test 'Overview' of section 'Leaks'
[
Subtask: Test 'Problem Suspect 1' of section 'Leaks'
[
Subtask: Test 'Description' of section 'Problem Suspect 1'
[
Subtask: Test 'Thread Stack' of section 'Description'
[
Subtask: Test 'Shortest Paths To the Accumulation Point' of section 'Problem Suspect 1'
[
Subtask: Test 'Accumulated Objects' of section 'Problem Suspect 1'
[
Subtask: Test 'Accumulated Objects by Class' of section 'Problem Suspect 1'
[
Subtask: Test 'Thread Details' of section 'Problem Suspect 1'
[
Subtask: Test 'Thread Properties' of section 'Thread null'
[
Subtask: Test 'Thread Stack' of section 'Thread null'
[]
!SESSION 2024-02-18 15:30:58.655 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_141
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -application org.eclipse.mat.api.parse /home/lighthouse/hmblogs/java_pid3878.hprof org.eclipse.mat.api:suspects
Command-line arguments:  -os linux -ws gtk -arch x86_64 -consolelog -application org.eclipse.mat.api.parse /home/lighthouse/hmblogs/java_pid3878.hprof org.eclipse.mat.api:suspects

!ENTRY org.eclipse.mat.dtfj 4 0 2024-02-18 15:31:11.163
!MESSAGE 
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.mat.dtfj.InitDTFJ.stop() of bundle org.eclipse.mat.dtfj.
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:860)
        at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:474)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:546)
        at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1098)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.decFWSL(StartLevelManager.java:593)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:261)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.shutdown(StartLevelManager.java:216)
        at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.suspend(InternalSystemBundle.java:266)
        at org.eclipse.osgi.framework.internal.core.Framework.shutdown(Framework.java:685)
        at org.eclipse.osgi.framework.internal.core.Framework.close(Framework.java:583)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.shutdown(EclipseStarter.java:409)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:200)
        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:559)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.NoClassDefFoundError: com/ibm/dtfj/image/CorruptDataException
        at org.eclipse.mat.dtfj.InitDTFJ.stop(InitDTFJ.java:67)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:840)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:833)
        ... 19 more
Caused by: java.lang.ClassNotFoundException: com.ibm.dtfj.image.CorruptDataException
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 23 more
Root exception:
java.lang.NoClassDefFoundError: com/ibm/dtfj/image/CorruptDataException
        at org.eclipse.mat.dtfj.InitDTFJ.stop(InitDTFJ.java:67)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:840)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:833)
        at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:474)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:546)
        at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1098)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.decFWSL(StartLevelManager.java:593)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:261)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.shutdown(StartLevelManager.java:216)
        at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.suspend(InternalSystemBundle.java:266)
        at org.eclipse.osgi.framework.internal.core.Framework.shutdown(Framework.java:685)
        at org.eclipse.osgi.framework.internal.core.Framework.close(Framework.java:583)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.shutdown(EclipseStarter.java:409)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:200)
        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:559)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.ClassNotFoundException: com.ibm.dtfj.image.CorruptDataException
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 23 more

好不容易找到了资料,链接如下:

Eclipse Community Forums: Memory Analyzer » Stacktraces while parsing heap

建议换成最新的MAT

换成了MemoryAnalyzer-1.1.0.20110523-linux.gtk.x86_64.zip

解压后,在mat目录下执行如下命令:

翻到最后,都没报错

在hprof文件所在目录下,有对应的zip文件,下载到本地,使用浏览器打开看看结果。

 

这节学完了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值