1.

Which of the following is a garbage collection technique?(a) Cleanup model(b) Mark and sweep model(c) Space management model(d) Sweep modelI got this question in an international level competition.Origin of the question is Heap and Garbage Collection in division Classes and Methods of Java

Answer»

Correct answer is (b) Mark and SWEEP model

For explanation I would say: A mark and sweep garbage collection consists of TWO phases, the mark phase and the sweep phase. I mark phase all the objects reachable by java threads, NATIVE handles and other root SOURCES are marked alive and others are garbage. In sweep phase, the heap is traversed to find gaps between live objects and the gaps are marked free list used for allocating memory to new objects.



Discussion

No Comment Found

Related InterviewSolutions