IDisposable, does it really matter

后端 未结 9 2887
予麋鹿
予麋鹿 2021-02-20 09:19

Coming from C/C++ a long time ago I still have a habit of ensuring that all resources are cleaned up correctly. I always ensure Dispose is called on IDisposable classes and impl

9条回答
  •  粉色の甜心
    2021-02-20 09:41

    Not disposing database releated IDisposable objects is a reliable and efficient way to generate OutOfMemoryExceptions in environments.

    DataSet implements IDisposable and I've read that it is not necessary to call Dispose because the objects that need to be disposed for a dataset are only created at Design time (by the visual studio designer). I've never seen OOM from un-Disposed datasets (just OOM from enormous DataSets)

提交回复
热议问题