The questions on this set of questions are designed to help you understand why and how garbage collection works in Java applications. The questions are designed to help you understand the concepts and features of garbage collection.
The idea behind garbage collection is to get your program to stop allocating memory to unused objects while it’s executing and then reclaim it for use.
Once garbage collection is done, its done. Once your program is done with garbage collection we can assume that it will never be re-used and will not be run again. You should expect the program to run at most once every few years so don’t stress about re-using objects.
This is another reason it’s important to understand garbage collection because it helps us understand what garbage collection is and what it isn’t. If you ever have to use someone’s garbage collection then you might ask, “What garbage collection?” And most likely, they’ll reply, “Garbage collection.
Garbage collection is the process of destroying (or reclaiming) objects that are no longer needed by the application. There are several garbage collection algorithms and technologies that can be used to reclaim unused objects. There are several garbage collection techniques that will take care of a problem. Some garbage collectors are able to take advantage of the characteristics of your application to reclaim unused objects. The most common garbage collection technique is known as the reference counting garbage collection technique.
The reference counting garbage collector will often reclaim unused objects that were not actually referenced. This technique works by taking an object and storing a reference to it. During garbage collection, the application will take care to not use the reference to that object again.
A lot of applications are using a reference counting garbage collection technique, because the garbage collector tends to get a little greedy. This is why you can sometimes see references to objects that don’t have any references to them, because the garbage collector tends to make it a bit easier to reclaim them.