Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Best way to find memory leak

Reply
Thread Tools

Best way to find memory leak

 
 
lordy
Guest
Posts: n/a
 
      07-22-2006
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
 
Reply With Quote
 
 
 
 
Zoli
Guest
Posts: n/a
 
      07-22-2006
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


 
Reply With Quote
 
 
 
 
bowman
Guest
Posts: n/a
 
      07-22-2006
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 =----
 
Reply With Quote
 
lordy
Guest
Posts: n/a
 
      07-22-2006
On 2006-07-22, bowman <(E-Mail Removed)> 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
 
Reply With Quote
 
Nick Vatamaniuc
Guest
Posts: n/a
 
      07-24-2006
Lordy,

Please see this the GC Portal on java.sun.com.
http://java.sun.com/developer/techni...ming/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 <(E-Mail Removed)> 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


 
Reply With Quote
 
pranshu
Guest
Posts: n/a
 
      07-24-2006
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

 
Reply With Quote
 
Stephen Kellett
Guest
Posts: n/a
 
      07-25-2006
In message <(E-Mail Removed)>, lordy
<(E-Mail Removed)> 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

Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
 
Reply With Quote
 
lordy
Guest
Posts: n/a
 
      07-27-2006
On 2006-07-24, Nick Vatamaniuc <(E-Mail Removed)> wrote:
> Lordy,
>
> Please see this the GC Portal on java.sun.com.
> http://java.sun.com/developer/techni...ming/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
 
Reply With Quote
 
lordy
Guest
Posts: n/a
 
      07-27-2006
On 2006-07-24, pranshu <(E-Mail Removed)> 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
 
Reply With Quote
 
lordy
Guest
Posts: n/a
 
      07-27-2006
On 2006-07-25, Stephen Kellett <(E-Mail Removed)> wrote:
> In message <(E-Mail Removed)>, lordy
><(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to find memory leak in perl server Eric Pozharski Perl 0 06-09-2008 08:01 AM
How to find out memory leak? pluskid Ruby 2 02-26-2008 10:00 AM
memory leak using mtrace to find subirs C Programming 3 04-09-2006 09:00 PM
How to find Memory Leak Harsha C++ 1 11-13-2003 10:56 AM
Can you help me find my memory leak? Greg Baker C++ 4 09-02-2003 08:38 AM



Advertisments