The GC knows which objects are alive because it copies all live objects to a new memory area and all that are not copied are overwritten the next time.
Note that this is valid for current implementations of the GC in the Oracle VM. Other VMs could handle it another way.