简体   繁体   English

WebSphere 7-如何确定在运行时哪些对象正在耗尽堆内存?

[英]WebSphere 7 - How can I determine which objects are using up heap memory at runtime?

Issue: I have intermittent out of memory issues but WebSphere is recovering. 问题:我有间歇性的内存不足问题,但是WebSphere正在恢复。 I am trying to determine how I can find out what is using up most of the memory. 我试图确定如何找出大部分内存已耗尽。 I have app dynamics but it does not work for Websphere. 我具有应用程序动态功能,但不适用于Websphere。

Is the only way the way to determine what is using up most of the memory to have a heap dump from out of memory crash? 是唯一一种确定大部分内存用完以从内存不足崩溃中进行堆转储的方法吗?

Server: WebSphere 7.5 服务器: WebSphere 7.5

JAVA Version: IBM 1.6 JAVA版本: IBM 1.6

The IBM JVM has dump triggers, which allow you to trigger dumps quite flexibly. IBM JVM具有转储触发器,使您可以非常灵活地触发转储。 For example, you can configure the JVM to dump when a given method is entered: 例如,您可以将JVM配置为在输入给定方法时转储:

-Xtrace:trigger=method{java/lang/String.substring,coredump}

You can specify counts, too, so to produce a dump when a method is entered 1000 times and 1001 times: 您也可以指定计数,以便在输入方法1000次和1001次时产生转储:

-Xtrace:trigger=method{java/lang/String.getBytes,coredump,,1000,2}

Once you have the dump, using Eclipse Memory Analyser with the IBM extensions ( http://www.ibm.com/developerworks/java/jdk/tools/memoryanalyzer/ ) is a good option for doing the analysis. 完成转储后,使用带有IBM扩展( http://www.ibm.com/developerworks/java/jdk/tools/memoryanalyzer/ )的Eclipse Memory Analyzer进行分析是一个不错的选择。 The IBM extensions know how to parse the IBM dumps (as you'd expect), and also have intelligence about what patterns of memory usage indicate a potential problem. IBM扩展知道如何解析IBM转储(如您期望的那样),并且具有关于哪种内存使用模式指示潜在问题的智能。

You need a java monitoring tool. 您需要一个Java监视工具。 Dynatrace is my favorite. Dynatrace是我的最爱。 It's not free (and not affordable for an individual), but it'll tell you exactly how your memory is being managed. 它不是免费的(而且个人负担不起),但是它将告诉您确切的内存管理方式。 And I've used it with Websphere. 我已经在Websphere中使用了它。

Do you think you have a memory leak, or a load problem? 您是否认为内存泄漏或负载问题?

You can generate a Heap Dump (Snapshot of the heap at a point of time) and a Thread Dump/Javacore (List of threads in the JVM at a point of time) while WebSphere Application Server is running. 当WebSphere Application Server运行时,您可以生成一个堆转储(一个时间点的快照)和一个线程转储/ Javacore(一个时间点的JVM中的线程列表)。

To obtain the dumps, you will need to use the wsadmin tool. 要获取转储,您将需要使用wsadmin工具。 Start the wsadmin tool and execute the following commands. 启动wsadmin工具并执行以下命令。

JACL Version: JACL版本:

set jvm [$AdminControl queryNames WebSphere:type=JVM,process=<servername>,node=<nodename>,*]  
$AdminControl invoke $jvm generateHeapDump
$AdminControl invoke $jvm dumpThreads

Jython Version (Untested): Jython版本(未经测试):

jvm = AdminControl.queryNames ('WebSphere:type=JVM,process=<servername>,node=<nodename>,*')
AdminControl.invoke(jvm, 'generateHeapDump')
AdminControl.invoke(jvm, 'dumpThreads')

Replace servername & nodename with your values. 用您的值替换servernamenodename Be sure to take multiple dumps, before the error and after the recovery. 确保在错误发生之前和恢复之后进行多次转储。

Once the command is completed, the filenames will be returned. 命令完成后,将返回文件名。 Move these files to a different workstation (because analysis is a resource-intensive process) and analyze them using any tool of your choice. 将这些文件移动到其他工作站(因为分析是资源密集型过程),并使用您选择的任何工具对其进行分析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM