This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Each object that you create in your Java program takes up some memory. The Java virtual machine keeps track of what part of the computer's memory is occupied by objects and what part is free (ready to store new objects in).
In a programming language such as C++, you are required not only to allocate, but also to free the memory that you have allocated. When you are programming in C++, it can easily happen that you forget to free the memory of some object that you had allocated previously. Especially if the program becomes larger and more complicated, you can easily overlook that you should have freed some memory somewhere. When there are errors like that in a program, the program has memory leak: some block of memory is allocated and never freed.
Memory leaks can become a big problem, especially in long-running applications, where the amount of memory that the program has allocated grows and grows over time, slowing the whole system down, until eventually the program crashes because the computer doesn't have any more memory left to allocate.
In Java, this has been made much easier than in C++. You can create new objects, but you never have to free them yourself - the JVM frees objects automatically when they are not used anymore. The garbage collector is the process in the JVM that periodically frees the memory allocated for objects that are not used anymore.
Java's automatic memory management is a big advantage over C++, because you almost never have to worry about freeing objects, which means you can write your program in less time (you can be more productive) and the whole problem of memory leaks isn't there.