Explain how the .NET Framework performs automatic memory management.

Answer

Automatic memory management involves two major steps:

a. Allocation of memory
b. Release of memory

Allocation of memory: - When a new process is initialized, runtime reserves address space in memory for the process. This address space inside the memory is known as heap. At the very initial stage, the pointer is at the base address of managed heap. When the application creates an object, the garbage collector allocates memory in the address space immediately following the first object. As long as address space is available, the GC keeps allocating space to the objects one over another. Runtime allocates memory to an object by adding a value to a pointer pointing to previously allocated object. This makes it faster.

Releasing memory: - Garbage collector figures out the best time to perform collection. This is done on the basis of how memory was allocated. GC releases all the unused objects. To find which ones are not in use, GC examines the application’s roots. All the application roots are assigned to the objects or are set to null. A graph is formed on the basis of this and the objects which are not part of this graph are released from the memory.

All vb Questions

Ask your interview questions on vb

Write Your comment or Questions if you want the answers on vb from vb Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---