Here is the answer.
Garbage collection manages only memory, not other system resources. If your Java program has plenty of free memory, garbage collection will not be triggered automatically.
Usually all operating systems have limitations for using the number of file handles, sockets etc., which can be open. The limit is quite low for certain resources. If the memory of the system is 128 KB, the Java program can easily allocate all the resources available for handling files without filling up the heap. In this scenario, the Java program will fail. This situation is known as ‚??resource leak‚??. In other words, resource leak is an unintentional maintenance of references to non-memory resources.