Results 1 to 6 of 6

Thread: JAVA - What is garbage collection

  1. #1
    Join Date
    Feb 2009
    Posts
    5

    JAVA - What is garbage collection

    Hi,

    What is garbage collection?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: JAVA - What is garbage collection

    In computing, garbage collection (also known as GC) is a form of automatic memory management. The garbage collector or collector attempts to reclaim the memory used by objects that will never be accessed again by the application or mutator. Garbage collection was invented by John McCarthy around 1959 to solve the problems of manual memory management in his recently devised Lisp programming language.

    Many computer languages require garbage collection, either as part of the language specification (e.g. Java, C#, Dylan) or effectively for practical implementation (e.g. formal languages like lambda calculus); these are said to be garbage-collected languages. Other languages were designed for use with manual memory management, but have garbage collected implementations (e.g., C, C++). In either case, it is far easier to implement garbage collection as part of the language's compiler and runtime system, but post hoc GC systems exist, including ones that do not require recompilation. The garbage collector will almost always be closely integrated with the memory allocator.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: JAVA - What is garbage collection

    Garbage collection relieves programmers from the burden of freeing allocated memory. Knowing when to explicitly free allocated memory can be very tricky.

    A second advantage of garbage collection is that it helps ensure program integrity. Garbage collection is an important part of Java's security strategy. Java programmers are unable to accidentally (or purposely) crash the JVM by incorrectly freeing memory.

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: JAVA - What is garbage collection

    When a Java object becomes unreachable to the program, then it is subjected to garbage collection. The main use of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources
    can be reclaimed and reused.When an object is no longer referred to by any
    variable,java automatically reclaims memory used by that object.This is known as garbage collection.
    System.gc() method may be used to call it explicitly.

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: JAVA - What is garbage collection

    Java runtime system performs the garbage collection asynchronously depending on the available resources. When there are no more references to an object, the object is finalized and when the Garbage Collections starts these finalized objects gets collected.

    Sometimes you need to run garbage collector explicitly just before some memory intensive task. You can run garbage collector by this statement.

    System.gc();

    Finalization process can also be invoked explicitly using the following statement. After the execution of this statement all the objects those are without reference, are finalized.

    System.runFinalization();

  6. #6
    Join Date
    Dec 2009
    Posts
    7

    Re: JAVA - What is garbage collection

    garbage collection is collecting the allocated memory which is not in use..

    or

    garbage collection is the process of collecting the memory which is no longer used..

Similar Threads

  1. How to Force Garbage Collection In Java?
    By Sheenas in forum Software Development
    Replies: 6
    Last Post: 28-04-2011, 01:30 PM
  2. Does C Sharp provide automatic garbage collection ?
    By kALAMATHI in forum Software Development
    Replies: 3
    Last Post: 08-01-2011, 08:33 AM
  3. Java - help with Garbage Collection
    By Messenger in forum Software Development
    Replies: 4
    Last Post: 23-07-2010, 10:18 AM
  4. What is the Garbage Collection in PHP?
    By Emma.J in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 01:40 AM
  5. What are the different collection classes of java
    By Sacchidananda in forum Software Development
    Replies: 3
    Last Post: 24-11-2009, 03:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,830,146.19004 seconds with 16 queries