Garbage collection in Framework

Garbage collection is a process of releasing the memory used by the objects, which are no longer referenced. This is done in different ways and different manners in various platforms and languages.

When an program is loaded in the memory there will be a bunch of memory allocated for that particular program alone and loaded with memory. This bunch of memory is called Managed Heap(is nothing but a bunch of memory allocated for the program at run time). This amount of memory will only be used when an object is to be loaded in to the memory for that particular program.
This memory is separated in to three parts:

·         Generation Zero – Smaller size

·         Generation One – Medium size

·         Generation Two – Larger size

When we try to create an object by using NEW keyword the system will,

·         Calculate the number of bytes required for the object or type to be loaded in to the managed heap.

·         The CLR then checks that the bytes required to allocate the object are available in the reserved region. IF the object fits, it is allocated at the address pointed to by NextObjPtr.

·         These processes will happen at the Generation zero level.

Ebook Download
View all
Learn
View all