Garbage Collector
For those with experience in C++, Java's constructors will seem pretty familiar, although there are some differences. You'll look in vain, for example, for a destructor in Java. The JVM not only frees you of the need to call destructors to release memory, you can't do so even if you want to. This is all under the control of the JVM. There is a separate thread in the JVM for garbage collection, similar to that in Smalltalk.
There are two important aspects of this garbage collection thread. First, you can request, but not force, garbage collection, by a call to System.gc(). Second, because the garbage collector thread is a low-priority thread, if there are other, higher priority threads hogging the CPU, the garbage collector thread ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access