base implementation of garbage collection