What is the difference between Finalize() and Dispose() methods?

  • Object.Finalize() method releases unmanaged resources but don't assure garbage collection. It is called before the Garbage Collector reclaims the memory. It is also called as a destructor, which is complementary to the constructor, where memory allocation happens.
public class MyClass {
  ~MyClass() {
    // any custom release operations
  }
}
  • Object.Finalize() method releases unmanaged resources but don’t assure garbage collection. It is called before the Garbage Collector reclaims the memory. It is also called as a destructor, which is complementary to the constructor, where memory allocation happens.
public class MyClass {
  ~MyClass() {
    // any custom release operations
  }
}

Buy Me A Coffee

Found this article helpful? Please consider supporting!

Ram
Ram

I'm a full-stack developer and a software enthusiast who likes to play around with cloud and tech stack out of curiosity. You can connect with me on Medium, Twitter or LinkedIn.

Leave a Reply

Your email address will not be published. Required fields are marked *