Explain how garbage collection works in Java, and how you would diagnose a memory leak in a high-throughput, real-time application.