11.6 finally Block

Programs that obtain certain resources must return them to the system to avoid so-called resource leaks. In programming languages such as C and C++, the most common resource leak is a memory leak. Java performs automatic garbage collection of memory no longer used by programs, thus avoiding most memory leaks. However, other types of resource leaks can occur. For example, files, database connections and network connections that are not closed properly after they’re no longer needed might not be available for use in other programs.

Image Error-Prevention Tip 11.4

A subtle issue is that Java does not entirely eliminate memory leaks. ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.