What are the types of Garbage Collectors ?

Answers were Sorted based on User's Feedback



What are the types of Garbage Collectors ?..

Answer / gaurav

Reachability of an object
Tri-colour marking
Moving vs. non-moving
Copying vs. mark-and-sweep vs. mark-and-don't-sweep

Is This Answer Correct ?    4 Yes 0 No

What are the types of Garbage Collectors ?..

Answer / vijay m

What is Garbage Collection?
Garbage Collection in computer science is a form of
automatic memory management. The garbage collector, or just
collector, attempts to reclaim garbage, or memory occupied
by objects that are no longer in use by the program. Garbage
collection does not traditionally manage limited resources
other than memory that typical programs use, such as network
sockets, database handles, user interaction windows, and
file and device descriptors.

History:
Garbage collection was invented by John McCarthy around 1959
to solve problems in Lisp.

Basic principle of Garbage Collection:

The basic principles of garbage collection are:

Find data objects in a program that cannot be accessed
in the future
Reclaim the resources used by those objects

It is kind of interesting to know how the objects without
reference are found. Java normally finds all the objects
that have reference and then regards rest of the objects are
reference less – which is in fact a very smart way of
finding the unreferenced java objects.

Types of Java Garbage Collectors/Garbage Collection Algorithms:
On J2SE 5.0 and above, one can normally find the following
types of Java Garbage collectors that the programmers can
normally choose to do a garbage collection through JVM
Parameters.

The Serial Collector:

JVM Option Parameter: -XX:+UseSerialGC

The Throughput Collector or The Parallel Collector:

JVM Option Parameter: -XX:+UseParallelGC
Young Generation GC done in parallel threads
Tenured Generation GC done in serial threads.

Parallel Old Generation Collector:

JVM Option Parameter: -XX:+UseParallelOldGC
Certain phases of an ‘Old Generation’ collection can be
performed in parallel, speeding up a old generation collection.

The Concurrent Low Pause Collector:

JVM Option Parameter -Xincgc or -XX:+UseConcMarkSweepGC
The concurrent collector is used to collect the tenured
generation and does most of the collection concurrently with
the execution of the application. The application is paused
for short periods during the collection.
A parallel version of the young generation copying
collector is used with the concurrent collector.
The concurrent low pause collector is used if the option
-XX:+UseConcMarkSweepGC is passed on the command line.
-XX:+UseConcMarkSweepGC -XX:+UseParNewGC
Selects the Concurrent Mark Sweep collector.
This collector may deliver better response time
properties for the application (i.e., low application pause
time).
It is a parallel and mostly-concurrent collector and
and can be a good match for the threading ability of an
large multi-processor systems.

The incremental (sometimes called train) low pause collector:
JVM Option Parameter: -XX:+UseTrainGC
This collector has not changed since the J2SE Platform
version 1.4.2 and is currently not under active development.
It will not be supported in future releases.

Note that -XX:+UseParallelGC should not be used with
-XX:+UseConcMarkSweepGC .

The argument parsing in the J2SE Platform starting with
version 1.4.2 should only allow legal combination of command
line options for garbage collectors, but earlier releases
may not detect all illegal combination and the results for
illegal combination are unpredictable.

Benefits of Garbage Collection:
Garbage collection frees the programmer from manually
dealing with memory deallocation. As a result, certain
categories of bugs are eliminated or substantially reduced:

Dangling pointer bugs, which occur when a piece of
memory is freed while there are still pointers to it, and
one of those pointers is then used. By then the memory may
have been re-assigned to another use, with unpredictable
results.
Double free bugs, which occur when the program tries to
free a region of memory that has already been freed, and
perhaps already been allocated again.
Certain kinds of memory leaks, in which a program fails
to free memory occupied by objects that will not be used
again, leading, over time, to memory exhaustion.

Disadvantages of Garbage Collection:

Consumes computing resources in deciding what memory is
to be freed, reconstructing facts that may have been known
to the programmer often leading to decreased or uneven
performance.
Interaction with memory hierarchy effects can make this
overhead intolerable in circumstances that are hard to
predict or to detect in routine testing.
The moment when the garbage is actually collected can be
unpredictable, resulting in stalls scattered throughout a
session.
Memory may leak despite the presence of a garbage
collector, if references to unused objects are not
themselves manually disposed of. This is described as a
logical memory leak.The belief that garbage collection
eliminates all leaks leads many programmers not to guard
against creating such leaks.
In virtual memory environments, it can be difficult for
the garbage collector to notice when collection is needed,
resulting in large amounts of accumulated garbage, a long,
disruptive collection phase, and other programs’ data
swapped out.
Garbage collectors often exhibit poor locality
(interacting badly with cache and virtual memory systems),
occupy more address space than the program actually uses at
any one time, and touch otherwise idle pages.
Garbage collectors may cause thrashing, in which a
program spends more time copying data between various grades
of storage than performing useful work.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SOAP Interview Questions

what type of basic questions they are asked in Webservices?

3 Answers   Cognizant, TCS,


What is the use of having soap messages with attachments?

0 Answers  


Explain what is the properties in soapui?

0 Answers  


Explain the actions performed by soapui?

0 Answers  


Explain soap encoding?

0 Answers  






can we do method overloading in java based web services .i am using Axis2 frame work. how to configure the operatios(which are method overload) in services.xml file. plz help me in solving this

0 Answers  


What is entrust privacy service?

0 Answers  


what is web service and what are they?

3 Answers  


Mention the advantages of soap web services?

0 Answers  


what is shop?

0 Answers  


in soapui i am prepared test data and create request and run the request. response generated. this response data how to validate/verification. how to verify the xml data in database. write query to get xml response data in oracle query. pls help me

0 Answers  


Explain how you can parametrize the endpoints in soap ui?

0 Answers  


Categories