This article features
a review discussing the function of memory management in Microsoft .NET
framework in detail.
Microsoft .NET
framework memory management is taken care of by the Common Language Runtime,
CLR system. It is a great feature as it takes care of memory management in
Microsoft Dot Net framework and relieves the programmers from the duty of
memory management which includes allocating and freeing up the memory.
Thus, we see that memory is allocated to the instantiations of .NET objects in
a close manner from the managed heap, a pool of memory managed by the CLR.
Till the time
there is a reference to an object, either a direct reference to an object or
through a graph of objects, it is believed to be in use by the Common Language
R. When there is no reference to an object, and it cannot be reached or used,
it becomes garbage. However, it still holds on to the memory allocated to it.
Note that the Microsoft .NET framework memory management system consists of a
garbage collector that runs on periodical basis on a different thread from the
application's thread, which specifies all the unusable objects and get back the
memory allocated to them.
Garbage
Collector (GC) in Microsoft .NET framework can be defined as a
non-deterministic, compacting, mark-and-sweep garbage collector. It is in
running state only when a definite amount of memory has already been used or
the system is under pressure for memory. The Garbage Collector which is used
for memory management in Microsoft .NET framework is actually a generational
one. The objects are being assigned a generation and the newly formed objects
come under Generation 0. The objects which successfully overcome garbage
collection are named as Generation 1, and those objects of Generation 1 that
successfully survive another Garbage collection are known as Generation 2
objects.
The Microsoft
.NET framework utilizes objects till the Generation 2 objects and the objects
belonging to the higher generation objects are garbage collected less
frequently as compared to the objects belonging to lower generations. It helps
in enhancing the efficiency of garbage collection, as older objects are more
likely to have a superior lifetime than the newer objects. Therefore by removing
the older objects from the scope of a collection run, there would be lesser
number of objects which required checking and compacting in process of memory
management in Microsoft Dot Net framework.
No comments:
Post a Comment