Originally posted by Ajith Kallambella:
Good notes Kavitha. !!
Sorry for being picky, but I would just like to comment on two of your statements -
[b]First of all, garbage collection is vendor specific & is run as the lowest priority thread by the JVM (which is again vendor specific). Since its run as the lowest priority thread, one can't predict when gc will be run. It is normally run when there are no more threads ready for execution.
This is usually true, however because of the vendor dependency, it is better not to make any assumptions. There may be implementations of VM where GC is made a priority thread - VMs running on hardware where memory is very expensive, hand-held devices and PDAs for example. So let's just say GC is vendor specific and you cannot assume anything about the priority of the GC thread.
Second point to remember is automatic variables are gc'd when they go out of scope.
I would like to correct this statement and say, automatic variables become eligible for garbage collection when they go out of scope.
You can be assured you will not get very tricky questions about GC in the exam. The typical questions will be identifying when the object becomes eligible for garbage collection
Just my two cents worth ....
Originally posted by Matt DeLacey:
It has been said that local variables become eligible for garbage collection when they go out of scope. This sort of implies that there aren't eligible before then, but what happens if they are set to null before they go out of scope. Would they then be eligible for gc BEFORE they went out of scope?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton