Skip to Content
author's profile photo Former Member
Former Member

Garbage Collector

when and how the garbage collector delete the instance variables LIKE int i,float f;

class{

int i;

float f;

}

Add a comment
10|10000 characters needed characters exceeded

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2006 at 11:46 AM

    Hi Valery,

    What I said was it normally runs as a low priority thread but it runs as a high priority one when available memory goes dangerously low(See the answer above).

    Regards,

    Pooja.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 10, 2006 at 01:03 PM

    Hi Guruvulu,

    A key feature of Java is its garbage-collected heap, which takes care of freeing dynamically allocated memory that is no longer referenced. Because the heap is garbage-collected, Java programmers don't have to explicitly free allocated memory.

    TO have a clear understanding of garbage collection,refer the following link:

    http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html

    Regards,

    Anuradha.B

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 10, 2006 at 01:03 PM

    when instance itself is deleted.

    actually, they (any primitives) are part of instance and resides in memory allocated per instance, JVM / GC does not manage them separately

    VS

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 15, 2006 at 11:59 AM

    Hi Guruvulu,

    you can call the garbage collector by hand:

    Use

    Runtime.getRuntime().gc();

    Before and after calling the gc you can check the free memory of your machine:

    Runtime.getRuntime().freeMemory();

    So you can check if the gc has done something.

    Hope it helps,

    Kasrten

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 16, 2006 at 05:32 AM

    Hi Guruvulu Bojja,

    Garbage Collector: A very good Memory Manager.

    You can clear your queries by verifying these links...

    1. About Garbage Collector.

    http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)

    2. The Mysteries of Distributed Garbage Collection

    http://www.thinktecture.com/Resources/RemotingFAQ/Lifetime.html

    3. Java theory and practice: A brief history of garbage collection

    http://www-128.ibm.com/developerworks/java/library/j-jtp10283/

    4. Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework

    Part-I.

    http://msdn.microsoft.com/msdnmag/issues/1100/gci/

    Hope it helps.

    5. Part-II

    http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/

    6. Java's garbage-collected heap

    http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html(Click on next link to explore more)

    7. Reference Objects and Garbage Collection

    http://java.sun.com/developer/technicalArticles/ALT/RefObj/

    8. GC-FAQ's

    http://java.sun.com/docs/hotspot/gc1.4.2/faq.html

    Hope it helps.

    Regards,

    Maheswaran.B

    Message was edited by: Maheswaran B

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 24, 2006 at 12:43 PM

    Hi

    If you r using System.gc in your program explicitely it free all the instances other wise of you are not using one particular variable for longer time it would be automatically garbage collected.

    I think it help you to solve your problem.

    Thanks

    Mrutyunjaya Tripathy

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Karsten and Mrutyunjaya,

      you should not rely on "manually" calling any of the .gc() methods! E.g. in Netweaver the <b>.gc()</b> disabled with +DisableExplicitGC JVM option.

      And besides that, <b>.gc()</b> gives the JVM just a "suggestion" for a GC, there's no guarantee that such will happen.

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2006 at 07:59 AM

    Hi,

    The <b>Java garbage collector</b> runs as a low-priority thread, so it does most of its work when nothing else is going on, such as during idle time while waiting for user input.

    The only time the garbage collector must run while something high-priority is going on (i.e., the only time it will actually slow down the system) is when available memory has become dangerously low. This doesn't happen very often because the low-priority thread cleans things up in the background.

    This is actually an automatic process.

    Regards,

    Pooja.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.