In java no need to vary about free the resource allocation to object. jvm provides the functionality to free the resource allocation this process is called garbage collection. it is automatic process it can run automatically when the jvm is free.
you can also called garbage collection by force. but it can not run immediately.
An object is eligible for garbage collection when there are no more resources to that object. that time only object garbage collected by jvm.
this is an interview point of question
what is garbage collection?
The JVM's heap stores all objects created by an executing Java program. Objects are created by Java's "new" operator, and memory for new objects is allocated on the heap at run time. Garbage collection is the process of automatically freeing objects that are no longer referenced by the program. This frees the programmer from having to keep track of when to free allocated memory.
No comments:
Post a Comment