GC in dot net
1. GC is background thread of any .net application. It has low priority but when it comes to picture it gets real time priority.
2. When we create an object using new keyword, CLR first calculate the amount of memory required for that object.
3. There exists 3 Generation.
4. Generation 0,1 and 2.
5. After calculating the memory required for new object, CLR allocates the object next to previous object in memory.
6. If there doesn't exists enough space in generation 0, GC starts collecting the objects whose references are not found.
7. after collecting the objects it stats compacting the memory.
8. If it still not get enough space, it moves all Generation 0 objects to Generation 1.
9. New object gets created on Generation 0.
10. If there doesn't exists enough space at Generation 1, same process occurs in generation 1 and moves objects to Generation 2.
11. If there doesn't exists enough memory, it throws Memory exception.
This is micro blog.