The Java memory API
This section covers some of the unique constructs of the Java language, related to memory management.
free operators for Java or trying to explicitly control the garbage collection behavior in a JVM by, for example, hanging on to objects longer than their natural lifespans is a sure way of shooting yourself in the foot. There are, however, some mechanisms in the Java language that make it possible to help the GC by giving it "hints". Some of the available mechanisms are good and some are bad. Some should be used with caution to avoid unwanted side effects.
In Java, since Java 1.0, every object contains a method called
finalize that may be freely overridden by any implementer. The contract is that ...