What is meant by “managed” vs “unmanaged” resources in .NET?

前端 未结 5 597
余生分开走
余生分开走 2020-11-28 03:29

What is meant by the terms managed resource and unmanaged resource in .NET? How do they come into the picture?

5条回答
  •  失恋的感觉
    2020-11-28 03:55

    The basic difference between a managed and unmanaged resource is that the garbage collector knows about all managed resources, at some point in time the GC will come along and clean up all the memory and resources associated with a managed object. The GC does not know about unmanaged resources, such as files, stream and handles, so if you do not clean them up explicitly in your code then you will end up with memory leaks and locked resources.

    For more details - http://bytes.com/topic/c-sharp/answers/276059-what-unmanaged-resources

提交回复
热议问题