The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused.Garbage collector is invoked automatically by JVM. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used and by unreachable mean that there are no references of that object on the stack.You can also specify when to invoke garbage collector using System.gc() but it is not necessary that JVM will always invoke garbage collector on encountering this function.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment