Why can .NET not have memory leaks?

前端 未结 16 1406
春和景丽
春和景丽 2020-12-07 16:17

Ignoring unsafe code, .NET cannot have memory leaks. I\'ve read this endlessly from many experts and I believe it. However, I do not understand why this is so.

It is

16条回答
  •  暖寄归人
    2020-12-07 17:15

    After reviewing Microsoft documentation, specifically "Identifying Memory Leaks in the CLR", Microsoft does make the statement that as long as you are not implementing unsafe code within your application that it is not possible to have a memory leak

    Now, they also point out the concept of a perceived memory leak, or as was pointed out in the comments a "resource leak", which is the use of an object that has lingering references and is not disposed of properly. This can happen with IO Objects, DataSets, GUI elements, and the like. They are what I would typically equate to a "memory leak" when working with .NET, but they are not leaks in the traditional sense.

提交回复
热议问题