Solved

moniotring JVM heap size

Posted on 2006-11-30
9
2,789 Views
Last Modified: 2012-06-27
I have a java application that creates a fairfew jvm's on the server it runs on.

What is the best way to measure the utaliseation of each JVM is.

I want to be able to see which JVMs are about to run out of memory in its heap.

are there any trick bits of softwar eout their that that might cater for my need that anyone knows of! ;)

Willa
0
Comment
Question by:willa666
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 18051321
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 18051327
> are there any trick bits of softwar eout their that that might cater
> for my need that anyone knows of! ;)


Quite simple theory: create an object, when you are done with it make sure that its dereferenced.
0
 
LVL 1

Author Comment

by:willa666
ID: 18051453
Hello Ajay-Singh

will this let me moniotr multiple(20-50) Jvms at once?

I am only concerned with knowing if a JVM is going to run out of memory.
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 18051657
I think you should - but more than monitoring this tool points out memory leaks and cpu, gc timings.


To monitor only monitoring, you can start the jvm process with jmx enabled and monitor on jmx console. With this you can monitor heap/cpu usage very easily.

More: http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 35

Expert Comment

by:girionis
ID: 18052343
You might also try JProbe SUite (http://www.quest.com/jprobe/) (not free though).
0
 
LVL 5

Expert Comment

by:maclema
ID: 18320970
Here is a little chunk of HTML/JSP I use to monitor my JVM's.
<%!
    String displaySize(long size) {
            long ONE_KB = 1024;
               long ONE_MB = ONE_KB * ONE_KB;
               long ONE_GB = ONE_KB * ONE_MB;
      
        String displaySize;

        if (size / ONE_GB > 0) {
            displaySize = String.valueOf(size / ONE_GB) + " GB";
        } else if (size / ONE_MB > 0) {
            displaySize = String.valueOf(size / ONE_MB) + " MB";
        } else if (size / ONE_KB > 0) {
            displaySize = String.valueOf(size / ONE_KB) + " KB";
        } else {
            displaySize = String.valueOf(size) + " bytes";
        }
        return displaySize;
    }
%>

<div><b>Max. Heap Size:</b> <%= displaySize(Runtime.getRuntime().maxMemory()) %></div>
<div><b>Cur. Heap Size:</b> <%= displaySize(Runtime.getRuntime().totalMemory()+Runtime.getRuntime().freeMemory()) %></div>
<div><b>Used Memory:</b> <%= displaySize(Runtime.getRuntime().totalMemory()) %></div>
<div><b>Free Memory:</b> <%= displaySize(Runtime.getRuntime().freeMemory()) %></div>

Hope that helps

Matt
0
 
LVL 5

Accepted Solution

by:
maclema earned 500 total points
ID: 18320987
Also keep this in mind:

Max Heap is the maximum allowable size that the heap can grow to.

Curr Hear is the currently allocated space that can be used for the heap.

Used Memory is the amount of the current heap that is used.

Free Memory is the amount of space left in the currently allocated heap size.

You will receive an out of memory error once the heap tries to expand past the maximum heap size.

- Matt
0
 
LVL 1

Author Comment

by:willa666
ID: 18323696
Hi maclema:

Is there a list of all the monitoring servlets anywhere on the net?

0
 
LVL 5

Expert Comment

by:maclema
ID: 18335058
What do you mean by a list of monitoring servlets?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

947 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now