Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting JVM Heap Size

Posted on 2009-07-11
14
2,856 Views
Last Modified: 2013-12-11
I am trying to find ways to the current Heap size of a JVM

For example if the max jvm size is 100 MB, I want a shell script or a java program or C program to check the HEAP size used by the JVM at any given point of time. I have searched the whole internet I could not find anything useful. If anyone can help me that should be great.
0
Comment
Question by:madhuthetom
  • 3
  • 3
  • 2
  • +3
14 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24830592
not sure there is a way from outside the jvm
see here for getting it within the jvm
http://www.exampledepot.com/egs/java.lang/GetHeapSize.html
0
 
LVL 92

Expert Comment

by:objects
ID: 24830597
and it would depend on the vm's being used
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24830988
You can get that info from outside the vm using jmap. See

http://it.toolbox.com/blogs/web2-place/how-to-get-details-on-jvms-heap-utilization-10609
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
LVL 41

Expert Comment

by:HonorGod
ID: 24831034
You mean the current heap utilization, or the maxHeapSize value?

If you mean that you want to analyze the heap utilization, you're going to have to use the PMI, as discussed here:

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tprf_monitoringhealth.html

If you want to get the maxHeapSize, that is much easier, e.g., something like this:
# This only works for an unManaged Server.
#---------------------------------------------------------------------
server = AdminConfig.list( 'Server' );
node   = AdminControl.getNode();
mHS    = AdminTask.showJVMProperties('[-serverName %s -nodeName %S -propertyName maximumHeapSize]' % ( server, node ) )
 
print 'Max Heap Size for server %s on node %s is %s' % ( server, node, mHS );

Open in new window

0
 
LVL 1

Author Comment

by:madhuthetom
ID: 24832073
HI thanks a lot for the idea.

But I Dont want to get the heap size for WAS server . I need to do it for websphere message broker
Borker does not expose any mbeans.so it has to be done only in shell script or C or java
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24832185
Isn't message broker a WebSphere Application Server application?

What version of Message Broker are you using?

0
 
LVL 1

Author Comment

by:madhuthetom
ID: 24832698
I am using WMB 6.1
0
 
LVL 2

Expert Comment

by:guneshraj
ID: 24834010
Please read about Java's Profiling (& related protocols), this could be done easily.
0
 
LVL 4

Expert Comment

by:dipinci
ID: 24834206
1. Are you looking to report the jvm (min /max) parameters being set for an exgrp?

This can be obtained by mqsireportproperties command
mqsireportproperties BrokerName -e ExgrpName -o ComIbmJVMManager -a

Or

2. Are you looking for JVM running within the biphttplistener process

I think there is no mqsiproperties to report the value, but the default value is 192MB.

To change the value,modify the message broker registry.

Windows

Under the registry key HKEY_LOCAL_MACHINE\SOFTWARE\IBM\WebSphereMQIntegrator\2\<BrokerName>\CurrentVersion create a new String value named MaxJVMHeapSize. Set this new String value to the JVM maximum heap size required in bytes. For example: 536870912 for 512 MB.

UNIX

In the directory <Broker File Path>/<Broker Name>/CurrentVersion/, create a new file named MaxJVMHeapSize. Set the contents of this file to the JVM maximum heap size required in bytes. For example: 536870912 for 512 MB.

For the changes to take affect, you will to stop and restart Message Broker.

or

3) If you are  looking for value of heap size occupied by exgrp jvm at a given point

 a)you can explore JVM  profiling as explained by Guneshraj.

 b) set the following in broker profile  
export MQSIJVERBOSE=-verbose:gc
This way, broker publishes an xml msg with details of exgrp jvm.
 it only publishes only when the exgrp starts up, not after that (ie: not periodically or so..)

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 25832671
Based upon the original question, http://#a24831034 appears to provide the most accurate answer to it.
0
 
LVL 4

Expert Comment

by:dipinci
ID: 25833568
Based on author requirement the answer for the question is ID: 24834206.
0
 
LVL 1

Accepted Solution

by:
madhuthetom earned 0 total points
ID: 25840033
I dont agree, Thats not what I watned. I have found the solution

I created a java compute node using java.lang.management to determine the help size, once it goes to 90% usage or more and sustains in high utilization for a while, I spin off another JVM instance.

But thanks to all for the help
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
throw exception 21 58
ejb on wildfly 5 30
ejb entity bean example 2 8
maven not picking latest jar instead picking old jar from .m2 12 17
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question