Update index.md fix typos and extra information (#24902)

* Update index.md

* fix: corrected a few typos
This commit is contained in:
Viplav K
2019-01-26 02:33:33 -05:00
committed by Randell Dawson
parent dbae7c6d24
commit 1d524f9746

View File

@ -9,15 +9,16 @@ In general layman term, Garbage collection (GC) is nothing but collecting or gai
Garbage collection is the process in which programs try to free up memory space that is no longer used by objects, and such. Garbage collection is implemented differently for every language. Most high-level programming languages have some sort of garbage collection built it. Low-level programming languages may add garbage collection through libraries.
As said above, every programming language has their own way of GC. In C programming, developers need to take care of memory allocation and deallocation using malloc() and dealloc() functions. But, in case of C# developers no need to take care of GC and it's not recommended as well.
As said above, every programming language has their own way of GC. In C programming, developers need to take care of memory allocation and deallocation using malloc() and dealloc() functions. C# developers don't need to take care of GC and is not recommended either.
#### How memory allocation happening?
In C#, memory allocation of objects happens in a managed heap. which takes care by CLR (common language runtime). Memory allocation for the heap is done through win32 dll in OS as like in the C. But, In C objects are placed in memory where ever the free space suits the size of object. And, the memory mapping is woks based on Linkedlist concepts. In C#, memory allocation for heap is happening in linear manner. like one after another.
Whenever a new object is being created. A memory is allocated in the heap and the pointer moved to next memory address. Memory allocation in C# is faster than in C since the memory needs to be searched and allocated for the object. so it will take a bit higher time than C#.
In C#, memory allocation of objects happens in managed heap. which takes care by CLR (common language runtime). Memory allocation for the heap is done through win32 dll in OS as like in the C. But, In C objects are placed in memory where ever the free space suits the size of object. The memory mapping works based on Linkedlist concepts. In C#, memory allocation for heap is happening in linear order like one after another.
Whenever a new object is being created, a chunk of memory is allocated in the heap and the pointer moved to next memory address. Memory allocation in C# is faster than the C. Since, in C the memory need to search and allocate for the object. so it will take a bit higher time than C#.
#### Generations in C# GC?
In .net programming, heap has three generations called generation 0, 1, 2. Generation 0 get filled first whenever new object is create. Garbage collector run when the Generation 0 get filled. newly created objects are placed in Generation 0. While performing garbage collection all the unwanted objects are destroyed, memory gets freed and compacted. GC takes care of pointing the pointers of freed memory once GC happens.
In .NET programming, heap has three generations called generation 0, 1, 2. Generation 0 gets filled first whenever new object is created. Garbage collector is executed when the Generation 0 gets filled. Newly created objects are placed in Generation 0. While performing garbage collection all the unused objects are destroyed, memory gets freed and compacted. GC takes care of clearing the pointers of freed memory once GC is executed.
Generations 1 and 2 has object which has the longer life time. GC on generations 1 and 2 will not happen until the generations 0 has sufficient memory to allocate.