On Wed, Aug 14, 2013 at 5:58 PM, Chris Hostetter <hossman_luc...@fucit.org> wrote: > > : > FieldCaches are managed using a WeakHashMap - so once the IndexReader's > : > associated with those FieldCaches are no logner used, they will be garbage > : > collected when and if the JVMs garbage collector get arround to it. > : > > : > if they sit arround after you are done with them, they might look like the > : > ytake upa log of memory, but that just means your JVM Heap has that memory > : > to spare and hasn't needed to clean them up yet. > : > : I don't think this is correct. > : > : When you register an entry in the fieldcache, it registers event > : listeners on the segment's core so that when its close()d, any entries > : are purged rather than waiting on GC. > : > : See FieldCacheImpl.java > > Ah ... sweet. I didn't realize that got added. > > (In any case: it looks like a WeakHashMap is still used in case the > listeners never get called, correct?) >
I think it might be the other way around: i think it was weakmap before always, the close listeners were then added sometime in 3.x series, so we registered purge events "as an optimization". But one way to look at it is: readers should really get closed, so why have the weak map and not just a regular hashmap. Even if we want to keep the weak map (seriously i dont care, and i dont want to be the guy fielding complaints on this), I'm going to open with an issue with a patch that removes it and fails tests in @afterclass if there is any entries. This way its totally clear if/when/where anything is "relying on GC" today here and we can at least look at that.