?
Solved

heap dump profile

Posted on 2003-10-27
9
Medium Priority
?
676 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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