[JAVA-1519] DBCursor finalizer should not hold on to the query results Created: 27/Oct/14  Updated: 30/Jan/15  Resolved: 28/Oct/14

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: None
Fix Version/s: 2.13.0, 3.0.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

DBCursor has a field that is populated with an instance of a class with a finalize() method, which is used to close a dangling cursor. But the class is an inner class, and therefore references the DBCursor instance, which in turn references the last query batch. This stresses out the garbage collector, which now has to keep all those objects alive until finalize() is called.

A better design would be to make the class with the finalizer a static inner class that only references the cursor id and server address.



 Comments   
Comment by Githook User [ 30/Jan/15 ]

Author:

{u'username': u'evanchooly', u'name': u'Justin Lee', u'email': u'jlee@antwerkz.com'}

Message: Merge pull request #272 from jyemin/j1519

JAVA-1519: DBCursor's OptionalFinalizer inner class is now static ...
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/642d65de08127e8dbaf3cbabf6a5ead3a7123ffb

Comment by Githook User [ 30/Jan/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: DBCursor's OptionalFinalizer inner class is now static and only contains fields for a Mongo instance and a ServerCursor instance.
Doing this prevents it from holding references to the DBCursor state which it does not actually need, allowing the garbage collector
to reclaim that memory before the finalizer runs.

JAVA-1519
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/7eb81d7a8391b7a7d5099ef900c2fea66c96e9ec

Comment by Jeffrey Yemin [ 29/Jan/15 ]

2.13.0 has been released. Closing issue.

Comment by Githook User [ 28/Oct/14 ]

Author:

{u'username': u'evanchooly', u'name': u'Justin Lee', u'email': u'jlee@antwerkz.com'}

Message: Merge pull request #272 from jyemin/j1519

JAVA-1519: DBCursor's OptionalFinalizer inner class is now static ...
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/642d65de08127e8dbaf3cbabf6a5ead3a7123ffb

Comment by Githook User [ 28/Oct/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: DBCursor's OptionalFinalizer inner class is now static and only contains fields for a Mongo instance and a ServerCursor instance.
Doing this prevents it from holding references to the DBCursor state which it does not actually need, allowing the garbage collector
to reclaim that memory before the finalizer runs.

JAVA-1519
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/7eb81d7a8391b7a7d5099ef900c2fea66c96e9ec

Comment by Githook User [ 28/Oct/14 ]

Author:

{u'username': u'evanchooly', u'name': u'Justin Lee', u'email': u'jlee@antwerkz.com'}

Message: Merge pull request #274 from jyemin/JAVA-1519

JAVA-1519: DBCursor's OptionalFinalizer inner class is now static and only contains fields necessary to kill the cursor
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/6d089c04174b941c24673c7ada88bfe69adb16ab

Comment by Githook User [ 28/Oct/14 ]

Author:

{u'username': u'evanchooly', u'name': u'Justin Lee', u'email': u'jlee@antwerkz.com'}

Message: Merge pull request #274 from jyemin/JAVA-1519

JAVA-1519: DBCursor's OptionalFinalizer inner class is now static and only contains fields necessary to kill the cursor
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/6d089c04174b941c24673c7ada88bfe69adb16ab

Comment by Githook User [ 28/Oct/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: DBCursor's OptionalFinalizer inner class is now static and only contains fields necessary to kill the cursor.
Doing this prevents it from holding references to the DBCursor state which it does not actually need, allowing the garbage collector
to reclaim that memory before the finalizer runs.

JAVA-1519
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/74ba7bfd9e39b73b1ab1e7b14cee553487e21fe5

Comment by Jeffrey Yemin [ 27/Oct/14 ]
Generated at Thu Feb 08 08:54:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.