3
Reply

what is difference between destruct or and garbage collection ?

rahul jaiswal

rahul jaiswal

12y
4.9k
0
Reply

    Garbage Collector : GC automatically call when our object no longer used. It is applicable for Managed Code only [.Net code only]Destructor : Destructor is Finalize. We use for releasing un-managed code.

    Garbage Collector : GC automatically call when our object no longer used. It is applicable for Managed Code only [.Net code only]Destructor : Destructor is Finalize. We use for releasing un-managed code.

    1.The garbage collector is a part of the .NET environment that keeps track of objects and makes sure that objects are removed from memory when they are no longer needed.

    A destructor is a part of a class design. It's the opposite of a constructor. When you declare it the GC will call it when it destroys an object.

    2.The destruct or is a special member function which is invoked when an object is destroyed. It is the last method run by a class.

    The garbage collector is part of the framework, automatically manages memory, and non-deterministically collects unreferenced objects to avoid memory leaks.

    3.Both are used to destroy unallocated object in the memory.

    4. Destroy are called CLR (Common Language Run time) and Garbage Collection called by .net Framework.