What is the disadvantage of having each java object with its own garbage collection function/object? For example if an object is not referred by anything in the application the object will remove itself from the memory/ heap. In theory if the object is not wanted or used by anything in the application it will clear itself from memory. Is this possible?
Java garbage collection
Collapse
X
-
garbage collector will remove the memory occupied by the object if it isn't referenced by any variable in the program. The object can't clear itself from memory. -
Only garbage collector perform memory cleanup. Unlike C\C++, where an object must be destroyed manually using the delete operator, java handles memory deallocation automatically by a process called garbage collection.Comment
Comment