lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smiley <dsmi...@mac.com>
Subject Re: CachedSearcher
Date Wed, 17 Jul 2002 02:40:34 GMT

On Tuesday, July 16, 2002, at 01:23  PM, Scott Ganyo wrote:

> Point taken.  Indeed, these were general recommendations that 
> may/may not
> have a strong impact on Lucene's specific use of finalization.  My only
> specific performance claim is that there will be a negative impact 
> of some
> degree using finalizers.  Whether that impact is noticable or not will
> probably depend upon a number of factors.  So I will avoid making any
> further judgements on the impact of finalization in Lucene on the
> performance until I have proof.
>
> Benchmarks aside, my point on the file handles is something that hit us
> square between the eyes.  Before we started caching and explicitly 
> closing
> our Searchers we would regularly run out of file handles because of 
> Lucene.
> This was despite increasing our allocated file handles to ludicrous 
> levels
> in the OS.  I would recommend that, in general, Java developers 
> would be
> well advised to explicitly release external resources when done with 
> them
> rather than allowing finalization to take care of it.
>
> Scott
>

Ahh, I take back my last comment about renaming close() to 
dispose().  If the IndexReader simply had a bunch of in-memory data, 
then dispose() would be appropriate.  If it holds onto resources 
outside of the VM (typical examples are Window objects, file streams, 
network sockets, etc. then close() should be one of those mandatory 
methods to be invoked when done with it.  In general one should *not* 
/rely/ on the GC to clean up external resources.  That's an important 
lesson repeated in various articles and books and testimonials I've 
learned over years of Java development.

This might clear up the issues some people have been having with not 
having enough file handles available on their OS.

~ David Smiley


--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message