Best way to find memory leak

Discussion in 'Java' started by lordy, Jul 22, 2006.

  1. lordy

    lordy Guest

    I've got a big app and I need a tool that can quickly help me locate a
    memory leak. Luckily, the app can run in a fast mode (60x), so
    one option is to run it with JRocket and use the Leak Detector.
    (The developer license allows me to run it for one hour, which is enough
    time for the leak to appear running in fast mode).

    Are the any other neat tools for this.

    Thanks.
    Lordy
     
    lordy, Jul 22, 2006
    #1
    1. Advertising

  2. lordy

    Zoli Guest

    Try JProfiler!
    Z


    > I've got a big app and I need a tool that can quickly help me locate a
    > memory leak. Luckily, the app can run in a fast mode (60x), so
    > one option is to run it with JRocket and use the Leak Detector.
    > (The developer license allows me to run it for one hour, which is enough
    > time for the leak to appear running in fast mode).
    >
    > Are the any other neat tools for this.
    >
    > Thanks.
    > Lordy
     
    Zoli, Jul 22, 2006
    #2
    1. Advertising

  3. lordy

    bowman Guest

    lordy wrote:

    > Are the any other neat tools for this.


    Valgrind on Linux. There is a note in the FAQ about dynamically generated
    code and a flag.


    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    bowman, Jul 22, 2006
    #3
  4. lordy

    lordy Guest

    On 2006-07-22, bowman <> wrote:
    > lordy wrote:
    >
    >> Are the any other neat tools for this.

    >
    > Valgrind on Linux. There is a note in the FAQ about dynamically generated
    > code and a flag.


    Thanks, but I think this only works at the System heap memory level. I
    want to find Java objects that are not getting GC'ed and why..

    Cheers,
    Lordy
     
    lordy, Jul 22, 2006
    #4
  5. Lordy,

    Please see this the GC Portal on java.sun.com.
    http://java.sun.com/developer/technicalArticles/Programming/GCPortal/
    There is way to run the JVM with the verbose GC options for example:
    -verbose:gc
    -XX:+PrintGCTimeStamps
    -XX:+PrintGCDetails
    There you will also find references to visualgc and jvmstat
    http://java.sun.com/performance/jvmstat/visualgc.html
    http://java.sun.com/performance/jvmstat/

    A quick and dirty way is to test the limits of your program is to
    stress test it. For example instead of having it run for 10 minutes and
    creating 1000 objects as normally does, have it run for 5 hours and
    create 1000000 objects and just look at your memory. It is just sort of
    a real-life testing. If your program works will under x100 the 'normal'
    conditions, it is probably 'good enough'. In other words you could
    spend 2 days finding 'leaks' and tunning the GC only to get a tiny
    performance boost - it might not be worth it altogether, but you would
    know better of course...

    Hope this helps,
    Nick Vatamaniuc


    lordy wrote:
    > On 2006-07-22, bowman <> wrote:
    > > lordy wrote:
    > >
    > >> Are the any other neat tools for this.

    > >
    > > Valgrind on Linux. There is a note in the FAQ about dynamically generated
    > > code and a flag.

    >
    > Thanks, but I think this only works at the System heap memory level. I
    > want to find Java objects that are not getting GC'ed and why..
    >
    > Cheers,
    > Lordy
     
    Nick Vatamaniuc, Jul 24, 2006
    #5
  6. lordy

    pranshu Guest

    Hi Lordy,
    If you know there is a memory leak and have the steps to reproduce it,
    then you have good tools. Essentially, you need to look for profilers
    which can do memory profiling ( most of them do) - like Jprobe which I
    have used and found to be good.
    You have to setup the application to profile using the profiler,
    execute the steps for the first time manually,call GC , take a
    snapshot of memory, execute the same steps for the second time
    manually, call gc again and take a snapshot again. Now if you diff the
    two snapshots you will know which are the culprit objects. The first
    step is necessary so that you donot count cached objects or the ones
    you want to live in memory.

    If you donot know if there is a memory leak, then it will be best to do
    a performance test by recording the frequently used scenarios and
    executing a load test over time.

    You will need to look at the memory utilization of the JVM and see if
    it is consistently growing with time. It sometimes help if you can code
    a JSP which explicitly calls GS and invoke that once in a while - just
    so that you know which points to take in the graph.

    Regards
    Pranshu
     
    pranshu, Jul 24, 2006
    #6
  7. Stephen Kellett, Jul 25, 2006
    #7
  8. lordy

    lordy Guest

    On 2006-07-24, Nick Vatamaniuc <> wrote:
    > Lordy,
    >
    > Please see this the GC Portal on java.sun.com.
    > http://java.sun.com/developer/technicalArticles/Programming/GCPortal/
    > There is way to run the JVM with the verbose GC options for example:
    > -verbose:gc
    > -XX:+PrintGCTimeStamps
    > -XX:+PrintGCDetails
    > There you will also find references to visualgc and jvmstat
    > http://java.sun.com/performance/jvmstat/visualgc.html
    > http://java.sun.com/performance/jvmstat/
    >
    > A quick and dirty way is to test the limits of your program is to
    > stress test it. For example instead of having it run for 10 minutes and
    > creating 1000 objects as normally does, have it run for 5 hours and
    > create 1000000 objects and just look at your memory. It is just sort of
    > a real-life testing. If your program works will under x100 the 'normal'
    > conditions, it is probably 'good enough'. In other words you could
    > spend 2 days finding 'leaks' and tunning the GC only to get a tiny
    > performance boost - it might not be worth it altogether, but you would
    > know better of course...
    >
    > Hope this helps,
    > Nick Vatamaniuc


    Thanks for that. I did observe the lean during a stress test. I just
    wanted a quick way of pinpointing the hanging references. It turns out
    that some resultSets were not getting closed. Found using JRockit
    memory leak tools.

    Lordy
     
    lordy, Jul 27, 2006
    #8
  9. lordy

    lordy Guest

    On 2006-07-24, pranshu <> wrote:
    > Hi Lordy,
    > If you know there is a memory leak and have the steps to reproduce it,
    > then you have good tools. Essentially, you need to look for profilers
    > which can do memory profiling ( most of them do) - like Jprobe which I
    > have used and found to be good.
    > You have to setup the application to profile using the profiler,
    > execute the steps for the first time manually,call GC , take a
    > snapshot of memory, execute the same steps for the second time
    > manually, call gc again and take a snapshot again. Now if you diff the
    > two snapshots you will know which are the culprit objects. The first
    > step is necessary so that you donot count cached objects or the ones
    > you want to live in memory.


    Useful. Thanks.

    >
    > You will need to look at the memory utilization of the JVM and see if
    > it is consistently growing with time. It sometimes help if you can code
    > a JSP which explicitly calls GS and invoke that once in a while - just
    > so that you know which points to take in the graph.


    Yup. Did that.

    Lordy
     
    lordy, Jul 27, 2006
    #9
  10. lordy

    lordy Guest

    On 2006-07-25, Stephen Kellett <> wrote:
    > In message <>, lordy
    ><> writes
    >>I've got a big app and I need a tool that can quickly help me locate a

    >
    >>Are the any other neat tools for this.

    >
    > Java Memory Validator
    >
    > http://www.softwareverify.com/java/memory/index.html
    >

    Windows only :(.

    Lordy
     
    lordy, Jul 27, 2006
    #10
  11. lordy

    IchBin Guest

    lordy wrote:
    > On 2006-07-25, Stephen Kellett <> wrote:
    >> In message <>, lordy
    >> <> writes
    >>> I've got a big app and I need a tool that can quickly help me locate a
    >>> Are the any other neat tools for this.

    >> Java Memory Validator
    >>
    >> http://www.softwareverify.com/java/memory/index.html
    >>

    > Windows only :(.
    >
    > Lordy


    How about the java_home\bin\jconsole.exe

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
     
    IchBin, Jul 27, 2006
    #11
  12. lordy

    Guest

    YourKit Java Profiler ( http://www.yourkit.com ) can help you to find
    memory leak.

    Best regards,
    Vladimir
     
    , Jul 27, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg Baker
    Replies:
    4
    Views:
    432
    Karl Heinz Buchegger
    Sep 2, 2003
  2. Harsha

    How to find Memory Leak

    Harsha, Nov 12, 2003, in forum: C++
    Replies:
    1
    Views:
    873
    Amol Chavan
    Nov 13, 2003
  3. subirs

    memory leak using mtrace to find

    subirs, Apr 7, 2006, in forum: C Programming
    Replies:
    3
    Views:
    589
    jacob navia
    Apr 9, 2006
  4. Eric Pozharski
    Replies:
    0
    Views:
    2,780
    Eric Pozharski
    Jun 9, 2008
  5. pluskid

    How to find out memory leak?

    pluskid, Feb 25, 2008, in forum: Ruby
    Replies:
    2
    Views:
    286
    Chiyuan Zhang
    Feb 26, 2008
Loading...

Share This Page