haju
haju

Reputation: 1298

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. 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.

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

JAVA Version: IBM 1.6

Upvotes: 0

Views: 396

Answers (3)

Holly Cummins
Holly Cummins

Reputation: 11492

The IBM JVM has dump triggers, which allow you to trigger dumps quite flexibly. For example, you can configure the JVM to dump when a given method is entered:

-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:

-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. 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.

Upvotes: 2

Haxiel
Haxiel

Reputation: 693

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.

To obtain the dumps, you will need to use the wsadmin tool. Start the wsadmin tool and execute the following commands.

JACL Version:

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

Jython Version (Untested):

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

Replace servername & nodename with your values. 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.

Upvotes: 0

Eric
Eric

Reputation: 153

You need a java monitoring tool. Dynatrace is my favorite. 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.

Do you think you have a memory leak, or a load problem?

Upvotes: 0

Related Questions