Search code examples
javawebspherewebsphere-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. 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


Solution

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