Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
In the section "Garbage Collection and Finalization of Objects," Venners says "Implentations [of JVMs] can decide when to garbage collect unreferenced objects -- or even decide whether to garbage collect them at all." This implies that gc() is only a suggestion that it is okay by you (performance-wise, I would imagine) for the garbage collection to do its thing. Eckel's book also implies this under "Order of garbage collection," though he doesn't specifically mention gc(), either. Several books have it outright wrong and state that gc() forces garbage collection (maybe you saw one of these). The specification is pretty clear on the subject: "Calling this method suggests that the Java Virtual Machine expend effort toward recycling discarded objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to recycle all discarded objects." The key word being "suggests," of course. Like the old "register" keyword in C/C++. So the answers to your questions are: - Matt > class Book{
Replies: |
Sponsored Links
|