You can have resource leakage if you do not properly close resources in your application after using them. For example, in a JDBC program, you should always properly close result sets and statement objects, because if you don't your program will run into problems after running a while.
Resource leak just means grabbing some resource (memory is probably most common) and never giving it back. This:
will rapidly use all the memory you have. That one is real obvious. Collections, especially referenced by static variables, are often the culprits in memory leaks. Some of the others mentioned above, like failing to close a connection, are far less obvious.
The finally clause is a good tip, too. Look how dangerous this is:
If the exception happens the "release" line is skipped. Oops. Moving release to a finally clause helps make sure the release is always done:
Study up on the life-span of objects ... local variables, member variables, thread-locals, statics. Make sure the objects you make will eventually be freed up for garbage collection. Pay attention to exceptions and the APIs for libraries like JDBC which should document places to take extra care. [ February 02, 2006: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi