-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: Performance
-
None
-
Not Needed
The DBCursor class has from its very beginning relied on Java's finalization mechanism to kill server-side cursors for abandoned un-exhausted DBCursor instances (ones that have not been fully iterated on the server and non explicitly killed). A couple of improvements have been made to the driver's use of this mechanism over the years, including:
- moving the finalization to a separate, internal class whose instances are only created when there is actually a cursorId (and thus would require at least one getMore to exhaust the cursor
- providing a way to disable finalization (though the default is still to leave it enabled)
In Java 9, the Cleaner class was introduced to the JDK as a more performant alternative to finalization, but the driver does not rely on it because Java 8 is still the minimum supported version.
However, the driver could still make use of Cleaner by detecting at runtime whether the Cleaner class is available, and only fall back to finalization if it's not.