I don't have a commiter-bit, so i can't say for a fact that a patch like this would/wouldn't be accepted, but it seems like a pretty simple change...
1) add a "public void suggestRemove(IndexReader r)" method to FieldCache.java 2) add an implimentation of that method to FieldCacheImpl.java which calls cache.remove(r) ...even without a patch, you should be able to do the same thing by writting your own subclass of FieldCacheImpl and assigning an instance of it to FieldCache.DEFAULT before you open any IndexReaders. BUT! I would seriously question wether or not this is needed, i'm hard pressed to think of any situation in which the GC wouldn't clean up those weak refrences for you in a timely manner ... unless ... perhaps ... you still have a hard refrence to your IndexReader somewhere that you aren't noticing which you don't let go of for quite a while? : Date: Wed, 15 Jun 2005 23:55:20 -0700 : From: John Wang <[EMAIL PROTECTED]> : Reply-To: java-user@lucene.apache.org, John Wang <[EMAIL PROTECTED]> : To: java-user@lucene.apache.org : Subject: dangers of fieldcache : : Hi: : : I am having some problems with the field cache. : : My application keeps a reader in memory for a amount of time and : then polls for a new reader, at which point a new reader is loaded : into memory and the older reader is then closed. : : However, after the reader is loaded, I do some operations such as : sorting which implicitly makes use of and stores data into the default : field cache, which lives in the static memory. : : Now even if I close the reader, the huge amounts of data remains in : the field cache. There isn't a way to flush or clear the fieldcache, : one can only rely the GC do the right thing and pull the soft : references from the WeekHashMap. : : This is baaaaaaaaaaaaad for me. : : Can an method to flush the cache be added to FieldCache? Or any : other suggestions? : : Please let me know, I can file a bug/enhancement for this. : : Thanks : : -John : : --------------------------------------------------------------------- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]