The garbage collector is a program that runs on the Java Virtual Machine that automatically frees up memory from objects that are no longer being used by a Java application. It handles memory management by reclaiming the unused runtime memory and destroying objects that are no longer referenced. This makes Java memory efficient as the garbage collector removes objects from memory without applications having to manually free up space.