Garbage Collection This function automatically cleans up unused memory. Garbage Collection Types Tracing garbage collection Garbage Collection visits the object every cycle and checks the flag. This is a mark and sweep method that checks flags. In-use flags are put on objects that are used, and objects that are not marked clean up memory by deleting. Reference Counting Cleans up memory by checking the number of variables referencing an object. If the object reference keeps decr