There are a lot of posts on the internet about garbage collection mechanism, here I mainly make an easy summary
First, the concept
Referred to as GC, English is all called garbage Collector, that is, the garbage collector, in my understanding, that is, the system memory is no longer used and do not need to use objects, these objects need to be recycled
Ii. managed resources and unmanaged resources
Managed resources: Resources on the managed heap,. NET 80% are managed resource unmanaged resources: Resources not on the managed heap, common Io Stream objects, string connection objects, and so on are unmanaged resources
Third, the scope of the GC
GC primarily reclaims managed resources, cannot release unmanaged resources, and GC is not real-time, and unmanaged resources need to be released manually
Iv. How to manually release unmanaged resources
Implement IDispose interface or using (higher performance)
. NET garbage collection mechanism understanding