Solved

moniotring JVM heap size

Posted on 2006-11-30
9
2,792 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Spring Framework HTTPSession management 1 36
ForLoop Example 3 49
servlet filter example 37 63
Problem to Alipay 10 24
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

822 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