How Garbage Collector(GC) works?
Benefits of Garbage Collections are that it allows us to develop application without implementing logic to free memory. Also it allocates objects on memory very efficiently. It reclaims the objects those are no longer in use and frees the memory for new objects to be allocated. Also provides safe memory operations by making sure that one object cannot use other object
When Garbage collection(GC) Occurs or run?Garbage collection happens for below conditions.
- If system has low memory
- If the memory allocated to object exceeds.
- if GC.Collect get called.
- Gen 0
- Gen 1
- Gen 2