Amazon Interview Question
Software Engineer / DevelopersGarbage collection is the process of reclaiming the heap from objects that are eligible for garbage collection.
Few Important points for Garbage collection are:
1. Objects are created in heap.
2. Garbage collector is the demon thread which carries out GC. An object becomes eligible for gc if all its refernces become null.
3. Before removing the object for GC, the GC thread invokes the finalize method of the object and allows to perform the necessary cleanup
4. We have methods like Runtime.gc() or System.gc() , used to send gc requests to JVM.
5. if there is no heap for creating more objects , JVM throws Java.outofmemoryerror
Garbage Collection algos are: en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Tracing_garbage_collectors
1. Mark and Sweep
2. TriColor
its pink
- Anonymous August 12, 2011