It uses garbage collection to free the memory. By cleaning those objects that is no longer reference by any of the program.