File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes handling Memory leakage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "handling Memory leakage" Watch "handling Memory leakage" New topic

handling Memory leakage

Harish Tiruvile
Ranch Hand

Joined: Dec 01, 2005
Posts: 99

I read in java memory leakage happens .So can any one tell me how to handle memory leak in java .

I know we cannot force garbage collector ,but still, is there any way to handle memory leake by knowing JVM architecture.I mean by getting control over JVM (from java application) ,can i handle memory leakage?

Can any one please let me know the ways used by real-world applications to overcome memory lekage problem.
[ May 03, 2007: Message edited by: harish thrivile ]

Giving up is the easiest thing in the world to do..but holding it together when everything seems like falling apart is true strength!!
with regards, Harish.T
Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

If you want to learn about how GC works and how to tune it, this article will give you some insight.
That will tell you how to tune your JVM according to the kind of objects created by your application. However, the basic idea is to remove all references to a created object as soon as you are done with it. The GC (if tuned properly) will take care of the rest.
Also, this article tells about different kind of references available with java. Probably, that will help you too.
[ May 03, 2007: Message edited by: Nitesh Kant ]

apigee, a better way to API!
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Memory can be leaked in two cases: a bug in the JVM, or a bug in the application code. In the former case, you should file a bug report with Sun, in the latter case, fix the bug in the code.

You don't need to force the JVM to run the GC; it will do so automatically if it needs to.
I agree. Here's the link:
subject: handling Memory leakage
It's not a secret anymore!