How to analyze MAT with eclipse

拥有回忆 提交于 2019-12-23 05:07:08

问题


My web application is running in apache tomcat.

The classloader/component org.apache.catalina.loader.WebappClassLoader @ 0x7a199fae8 occupies 1,70,86,32,104 (88.08%) bytes.

The memory is accumulated in one instance of java.util.concurrent.ConcurrentHashMap$Segment[] loaded by <system class loader>.

I got this problem while analyzing Heapdump. How to analyze it further ?


回答1:


You provide very little information so I only can provide very little advice… ;-)

First you need to find out who is using the largest objects (the HashMap in your case). Try to look at the contents of the HashMap so you may find out what it is used for. You should also try to look at where this objects are referenced.

Than you can try to limit its size. Depending on whether it is used by a framework you use or by your own code this can be easy (e.g. configuration change for a frameworks cache), medium (e.g. you need to refactor your own code) or difficult (e.g. it is deeply buried in a library you have no control over).

Often the culprit is not the one you expect: Only because an object instance (in your case the HashMap) accumulates a lot of memory does not mean the "owner" of this object is the root cause of the problem. You might well have to look some levels above or below in the object tree or even in a completely different location. In most cases it is crucial that you know your application very well.

Update: You can try to inspect the contents of a HashMap by right clicking it and selecting Java Collections, Hash Entries. For general objects you can use List objects, with incoming references (to list all objects that reference the selected object) or with outgoing references (to list all object that are referenced by the selected object).


Memory analysis is not an easy task and can require a lot of time, at least if you are not used to it…

If you need further assistance you need to provide more details about your application, the frameworks you use and how the heap looks like in MAT.



来源:https://stackoverflow.com/questions/29590527/how-to-analyze-mat-with-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!