Garbage Collcetion is responsible for allocating & deallocating memeory needed to store Objects and Value types. Garbage Collcetor is part of CLR Memory Management System .
Garbage collection is automated in C#
Garbage Collector stores data based upon the Types.VALUE types are stored in STACK and Object are stored in HEAP.
When the Garbage Collector performs the operation of collection ,it checks for the object in the HEAP ,which haven't been accessed or used from some instance pf time and hence it removes such objects and allocates that memory (re-collected) to the newly created /generated objects .The location of the un used objects is known with the help of METADATA concept.The same process happnes same with the VALUE types too.
Rule: If the managed heap does not have sufficient memory to allocate a requested object, a garbage collection will occur.
Garbage collection steps 1. The garbage collector searches for managed objects that are referenced in managed code 2. The garbage collector attempts to finalize objects that are unreachable 3. The garbage collector frees objects that are unmarked and reclaims their memory
Automatic memory management • reduces programmer burden • eliminates sources of errors • integral to modern object-oriented languages, i.e., Java, C# • now part of mainstream computing • Challenge:– performance efficiency
|
| Author: Arun Kumar 05 Jun 2008 | Member Level: Bronze Points : 1 |
Please specify the generation in garbage collection to make it a good article
|
| Author: Mahesh Raj 07 Jun 2008 | Member Level: Gold Points : 1 |
This is very good information,Continue posting such useful articles.
|