One old, but cumbersome trick:
start with the previous version and change by little steps towards the final version.
That sometimes cost me weekends, but helped me more than tools.
;JOOP!
Main Topics
Browse All TopicsHello,
I have a rather complex java program which has decided to spring a memory leak after its latest revision. I have no idea where it could be as alot of things changed. Im in my final debug, and have fixed everything but came across this after some load testing. I cannot run the app through a normal desktop computer as it requires quite a few resources (so netbeans is out), so Im not sure how to go about determining where to concentrate my efforts.
Can anyone tell me how to go about this?
Worth 500 points.
Thanks,
Rick
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Similar to what sciuriware suggested, I recommend trying to turn off parts of the program bit by bit and see where the leak is located. I find that it usually is not that hard to create a few lines of code that mimic an entire section of the program, but return a fixed static answer without running all the logic. In addition to helping pinpoint the problem it usually makes the program faster, so that the problem occurs faster.
I also recommend limiting the memory given to the program so that the memory leak will become apparent sooner.
Start with the program you have right now, limit the memory (using java.exe -Xmx option) to something low, and let it run, so you can establish a baseline of how soon the memory leak occurs. Then replace a part of your code with a dummy method to simulate its function and see if it got rid of the problem. Do it, narrowing the location, until you find the problem.
Be sure to turn on the PrintGC flags (-XX:-PrintGC -XX:-PrintGCDetails -XX:-PrintGCTimeStamps), to get a feel of how the memory behaves - see http://java.sun.com/javase
In addition, I found that a lot of times collections (Map, Set, List) are the cause of the problem, since stuff just gets added to them, and sometimes no one deletes it.
HTH
Debugging the code is definitely one way to go.
You could also do actual performance analysis. JProbe is the best product out there for Java, but it's very expensive now. It's also hard to use.
Here's a good article from Sun about profiling performance:
http://java.sun.com/develo
and another very good article on performance analysis:
http://java.dzone.com/arti
There's a list of free tools at the end of the second article. JConsole is an easy way to start.
Hi!
Take a look at these Profilers to see if any of them can help you solve your issue
http://java-source.net/ope
Regards,
Tomas Helgi
Yes, if you look at the articles I provided, they give links to profiler tools. And as I said, JConsole is an easy way to start.
However, I have to agree with sciuriware and ozlevanon that it's usually faster to look at your code than to dig into profiling it for memory leaks. That's especially true if you have a version of the code that does not exhibit the bad behavior.
Business Accounts
Answer for Membership
by: federicomarinucciPosted on 2009-10-23 at 10:07:01ID: 25646347
Well, how could we help you?
Give us any hints, any piece of code which has been recently modified, otherwise I fear we can only tell you to endure with your debugging.