Java garbage collection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yene
    New Member
    • Oct 2009
    • 13

    Java garbage collection

    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?
  • anurag275125
    New Member
    • Aug 2009
    • 79

    #2
    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.

    Comment

    • Yene
      New Member
      • Oct 2009
      • 13

      #3
      Thank you for ur reply...275125 but why is it object can not remove itself from memory?

      Comment

      • anurag275125
        New Member
        • Aug 2009
        • 79

        #4
        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

        Working...