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 Garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Garbage collection" Watch "Garbage collection" New topic

Garbage collection

Praveen Chaudhary

Joined: Jul 09, 2009
Posts: 11
Hi All
How Jvm/compiler exactly locate that particular object is garbage collected when there is no reference available to that particular object.

Thanks & Regards
Praveen Chaudhary
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46352
Nice book chapter, but may be as old as 1996. More recent article about performance of grabage collection. IBM article about garbage collection and null values. Joel Spolsky article explaining that the notion that garbage collection is an unnecessary overhead is false.
Srikanth Visamangalam Thattai

Joined: Jul 24, 2007
Posts: 3
The garbage collector cannot ensure that there will always be enough memory.
The garbage collection (GC) algorithm varies from one JVM to another.
There are different algorithms being used, like reference counting or the mark and sweep algorithm.

Please google up for more insight to those algorithms.

To request garbage collection, you can call either of the following methods:

  • System.gc()
  • Runtime.getRuntime().gc()

  • Regards,

    Maneesh Godbole
    Saloon Keeper

    Joined: Jul 26, 2007
    Posts: 10825

    srikanth V T wrote:

    Please check your private messages for an important administrative matter.

    [How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
    Praveen Chaudhary

    Joined: Jul 09, 2009
    Posts: 11
    Hi javaranchers
    I am expecting a knowledgeable and in depth answer on this topic please reply .I know you know it.
    Rob Spoor

    Joined: Oct 27, 2005
    Posts: 20273

    It all depends on the garbage collector used. In Java the garbage collector has evolved quite a bit, and you can tune it. Check out the following sites:

    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
    How To Ask Questions How To Answer Questions
    I agree. Here's the link:
    subject: Garbage collection
    It's not a secret anymore!