The purpose of garbage collection is to identify and discard objects that are no longer needed by a programso that their resources may be reclaimed and reused.