[JAVA-179] Use weakrefs for static list of Mongo instances Created: 09/Oct/10 Updated: 29/Oct/10 Resolved: 17/Oct/10 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 2.2 |
| Fix Version/s: | 2.3 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Scott Hernandez (Inactive) | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Use weakrefs for Mongo instances create by static methods. http://github.com/scotthernandez/mongo-java-driver/commit/483b0372d37a3f699cacee7af852cfb809e08cbc |
| Comments |
| Comment by auto [ 17/Oct/10 ] |
|
Author: {'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}Message: let you have your own static Mongo pool, but not global |
| Comment by auto [ 17/Oct/10 ] |
|
Author: {'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}Message: some more work on MongoURI and removing some static |
| Comment by Eliot Horowitz (Inactive) [ 09/Oct/10 ] |
|
Yeah - that's kind of what i was thinking. |
| Comment by Scott Hernandez (Inactive) [ 09/Oct/10 ] |
|
What about a sep. singleton class (MongoCache/Factory) which manages this? It can have methods like the statics on Mongo but can also have a flush/clear method that you can call to move all the Mongo instances into weakrefs so that they can be garbabe collected if they want. It can be made very clear that working with the factory requires managing the life-time of the Mongo instances in a special way, manually. |
| Comment by Eliot Horowitz (Inactive) [ 09/Oct/10 ] |
|
Right - that was the idea. Maybe we can make a seperate thing for this instead of that static method... Will think about |
| Comment by Scott Hernandez (Inactive) [ 09/Oct/10 ] |
|
As long as they are being used they will stick around. The purpose is to always have them avail? That means they will not get cleaned up until the classloader is collected? |
| Comment by Eliot Horowitz (Inactive) [ 09/Oct/10 ] |
|
That kind of defeats the purpose... |