Solved

heap dump profile

Posted on 2003-10-27
9
668 Views
Last Modified: 2013-11-23
Hi

I have a problem with "OutOfMemoryException".
I have tried to make sure that my program doesn't leak memory using optimizeIt.
Nevertheless in some cases (on the field), the program stops with "OutOfMemException".

I've figured to that with the -Xrunhprof:heap=all flag, I can make the jvm dump its heap.
If I can analyze the heap I can determine if the app needs more memory or if it leaks.
The problem is that I can find no tool to analyze the XX Mb large heap dump.

Any hints? (I'm using java1.4@win2k.)

www.hpjmeter.com doesn't support java1.4.
The experimental "hat"-tool from sun doesn't work in 1.4.
http://prophit.westslopesoftware.com/ is closed?
PerfAnal (http://www.javalinux.net/CDROM/#JavaBinaries) is too old.

0
Comment
Question by:eklas
[X]
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
  • 4
  • 2
  • 2
9 Comments
 
LVL 7

Expert Comment

by:tomboshell
ID: 9626595
Interesting...I've always done manual checking.  Make sure all loops end correctly, no never-ending loops, counters don't reach infinity, recursive calls have ending situations that WILL be reached, close File I/O classes, and such.  That is the advice I could give, so I wait and listen to other expert advice--I might learn something :)
0
 

Author Comment

by:eklas
ID: 9626762
It's a fairly large GUI app (~100Mb ram).
Each dump is ~15mb.
Impossible to get an overview by reading the heap-dump text file.
0
 
LVL 1

Expert Comment

by:amswain
ID: 9627045
Have you tried setting the max heap size of the vm running the swing app.

java -Xmx256m

You could also run a thread inside you app

    /** Thread used to update the status bar with memory use */
    private Thread thread = new Thread( "Memory use thread" ) {
        public void run() {
            while( true ) {
                getStatusBar().setPercentMemoryUsed( MemoryManager.getPercentageUsed() );
                try {
                    Thread.sleep( 1500L );
                } catch ( InterruptedException ex ) {
                }
            }
        }
    };


class MemoryManager {

    /** The runtime environment */
    private static Runtime runtime = Runtime.getRuntime();

    /**
     *  The percentage used.
     */
    public static int getPercentageUsed() {
        long free = runtime.freeMemory();
        long total = runtime.totalMemory();
        double used = (total-free)/(double)total;
        return (int)(100*used);
    }
}

I have something like this running in my swing gui which is also quite memory hungry.
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

Author Comment

by:eklas
ID: 9627124
I need more detailed info than total amount of memory used.
I currently use "-Xmx100m".
I don't just want to increase mem by +30% without knowing why.
It might be a mem leak problem in some rase use case that I havn't covered in my tests.
To be 100% sure that the code doesn't leak mem I need to do a 100% code coverage in the my mem tests. Impossible. Therefore I need a heap dump _when_ the situation occurrs.
Compare to a thead dump (ctrl-beak, kill -QUIT <pid>).
Of course it must be possible to do something simliar on memory problems?!?
0
 
LVL 1

Expert Comment

by:amswain
ID: 9627205
Sure, I understand what you want to do but if there's a specific action in the gui that is causing the memory to go sky high then you should probably investigate that first.  I have found it quite useful to see what the memory is doing (on our status bar).  I used JProbe some time ago but it wasn't with java 1.4.  I can't give you any specific advice for java 1.4 i'm afraid.
0
 

Author Comment

by:eklas
ID: 9627665
Nope, the problem is not reproducible.
Any help for 1.3 or 1.4 will do.
0
 
LVL 7

Accepted Solution

by:
tomboshell earned 500 total points
ID: 9634053
I just ran across this while surfing the net: http://www.alphaworks.ibm.com/tech/heaproots?open&ca=daw-rss-s8
as they state it "HeapRoots is a tool for debugging memory leaks in JavaTM applications through analysis of "heap dumps.""

You might want to give it a whirl.
0
 

Author Comment

by:eklas
ID: 9636389
HeapRoot:s was a very nice tool.
If no-one can come up with with a tool compatible with Sun Jdk (that I can run on solaris),
your answer was the best available.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

688 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