Garbage collector is a piece of code responsible for allocating and freeing unreferenced objects in a managed application. Garbage collection operation is invoked whenever:
- the application calls GC.Collect() method
- CLR cannot allocate memory for an object
- the application loses focus and goes to the background
- the system sends WM_HIBERNATE message to the managed application