Solved

heap dump profile

Posted on 2003-10-27
9
651 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 86
Java Server Faces parameter pass? 6 50
Cipher Configuration on Apache HTTPD 4 63
even odd program using while loop 3 43
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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…

803 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