C# disposing IDisposable

后端 未结 7 2234
滥情空心
滥情空心 2021-01-14 02:44

Could someone explain what might happen if you don\'t Dispose some IDisposable entity (by using or direct Dispose cal

7条回答
  •  轮回少年
    2021-01-14 03:23

    IDisposable is meant to wrap an unmanaged resources (i.e. not .NET memory). So if you don't dispose them, you will leak things like open database connections, Window handles, file handles, etc. depending on what type of IDisposable you're failing to dispose.

    So it's not truly a memory leak, but it can lead to performance degradation and eventually a crash as you run out of the unmanaged resources.

提交回复
热议问题