lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Lucene's finalizeable objects
Date Fri, 20 Feb 2004 16:49:00 GMT
Eric Isakson wrote:
> These all look appropriate to me. These finalizers protect against a program consuming
system resources if a programmer forgets to call close and the object gets garbage collected.
This is similar to the handling by java.io.FileInputStream and java.io.FileOutputStream see:
> 
> http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html#finalize()

I never noticed that.  Thanks for pointing it out!  The presence of this 
probably makes Lucene's finalize() methods redundant, doesn't it?

> In a perfect world, these wouldn't be needed and people would always call close before
the objects become unreachable.

Having to call close() is like malloc/free or new/delete in C and C++, 
i.e., in an ideal world we shouldn't have to call them.  It's only 
required here because the OS isn't integrated with Java's GC.  But 
finalize() provides the hook to perform this integration.

Doug

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message