tags:

views:

312

answers:

2

Hi all,

cacn you please explain me ..

what is the algorithm of garbage collector.??

how garbage collector works in background..?

+1  A: 

Here is the basic idea for the GC.

==========================================

Every application has a set of roots. Roots identify storage locations, which refer to objects on the managed heap or to objects that are set to null.

For example:

-- All the global and static object pointers in an application. -- Any local variable/parameter object pointers on a thread's stack. -- Any CPU registers containing pointers to objects in the managed heap. -- Pointers to the objects from Freachable queue

The list of active roots is maintained by the just-in-time (JIT) compiler and common language runtime, and is made accessible to the garbage collector's algorithm

+2  A: 
Andreas Grech