difference between destructor and garbage collector

后端 未结 4 558
执念已碎
执念已碎 2020-12-31 19:18

I want to know is there any difference between destructor and garbage collector, destructor is used to dispose of all unused objects at the end of the lifetime of the applic

4条回答
  •  一整个雨季
    2020-12-31 19:52

    The destructor 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.

提交回复
热议问题