Garbage
Collector (GC)
–
Here
is how GC works and its advantages:
1.De-allocation or freeing of
resources consumed by created instances.
üIn
C#, the de-allocation or freeing of resources consumed by created instances
occurs automatically on a system-determined schedule by an intelligent
mechanism known as garbage collection.
üThe
Garbage Collector (GC) is like a sweeper fish in an aquarium.
üIf
you drop more food than the other fish can eat, the sweeper fish consumes the
remaining food without leaving anything behind.
üThe
convenience and usefulness of GC has been known since Java.
●
2.Runs simultaneously with
application
üThe
GC in C# improves on the concept because it does not reduce the system's
performance until really needed.
üIt
is smarter than other garbage collectors currently on the market.
üYou
can overcome the disadvantages of CG's nondeterministic behavior by using
destructors and finalizers.
üYou
can allocate member instances with constructors . Let's explore some important
aspects of garbage collecting in .NET.
3.Do not need to code destructors or finalizers
üIn
C#, most of the time, you do not need to code destructors or finalizers because you can trust GC to clean
up for you with destructors.
üThese
functions are called implicitly by the C# runtime system's garbage
collector.
4.If
explicit deterministic deallocation of objects is important in class and
inheritance hierarchy.
0 comments:
Post a Comment