Get the JVM heap utilisation for a running WebSphere server

Filed under: WebSphere — lars @ 05:39:32 am

I recently had to find out the amount of heap memory (the place a JVM stores it's object instances) being used by a running WebSphere v7.0 instance we suspected of being close to out of memory.

To do this, I could use the below jython script called '':

serverJVM=AdminControl.completeObjectName('type=JVM,process=' + sys.argv[0] + ',*')
perf=AdminControl.completeObjectName('type=Perf,process=' + sys.argv[0] + ',*')


print sys.argv[0] + ".> "+str(currentHeapsize)+"K .> "+str(usedMemory)+"K .> "+"Usage:%.2f" % usage+"%"

Which can then be executed as follows:

/opt/WebSphere/7.0/AppServer/profiles/AppSrv01/bin/ -lang jython -f server1

where "AppSrv01" is your profile name and "server1" is the server name - producing the following output:

server1 .> 893760K .> 483776K .> Usage:54.13%

Remember that WebSphere allows you to set an Initial as well as a Maximum heap size - if they're not the same then the heap size could be anywhere between these two values.  The output above will show you the percentage use of the *current* heapsize, which may not be the maximum.  Some recommend setting these to the same value to remove the performance overhead of the JVM needed to allocate more memory as it grows the heap.


  • shaikh
    thank you
    this makes it easy o find out what is ur jvm status rather than going to tivoli

    Comment by shaikh [Visitor] — 10/07/10 @ 01:57

  • Raj
    Nice work. It helped me using it in my WebSphere environment rather than reinventing the wheel. Thanks much.

    Comment by Raj [Visitor] — 05/20/11 @ 17:56

  • Sara
    Thanks for the script. It helped.

    Comment by Sara [Visitor] — 05/11/15 @ 20:36

  • Muneeb
    Your script worked like a charm, keep up the good work.
    I added condition for the 1st argument (whoever uses the script will be forced to enter the 1st arguemnt, otherwise it won't run)


    Comment by Muneeb [Visitor] — 02/23/16 @ 06:10

  • Daryl
    cool. very helpful. tnx

    Comment by Daryl [Visitor] — 08/05/16 @ 01:42

Leave a comment

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>

(Line breaks become <br />)
(Set cookies for name, email & url)

powered by  b2evolution