System.gc() to close file descriptors (was RE: status of gcj's bo ehm collector?)

Andrew Haley aph@cambridge.redhat.com
Tue Dec 11 11:15:00 GMT 2001


Boehm, Hans writes:
 > > From: Andrew Haley [mailto:aph@cambridge.redhat.com]
 > > Boehm, Hans writes:
 > > > Interesting. Unfortunately, I think the standard Java 
 > > interface isn't quite
 > > > sufficient to do that right. I think the logic to do this 
 > > properly is:
 > > > 
 > > > if (I'm out of file descriptors and need one, but not before) {
 > > > for (;;) {
 > > > 	System.gc();
 > > > 	System.runFinalization();
 > > > 	if (the preceding call ran no finalizers || file descriptor is
 > > > available) break;
 > > > }
 > > > } 
 > > > 
 > > > The loop is needed because running finalizers may result in
 > > > dropping more objects. If finalization dependencies are correctly
 > > > enforced (in Java the client code needs to do that), that's even
 > > > reasonably likely. I think this mean you really need
 > > > runFinalization to return an indication of whether or not it did
 > > > anything so that you can avoid a potentially infinite loop here.
 > > 
 > > What I'm wondering is whether this is a real or a theoretical
 > > requirement for gcj. So, for our current implementation, is there any
 > > chance that calling System.gc() might not call finalizers for files
 > > that are garmbge before returing? 
I can confirm that this really is broken in the current libgcj.
Here's a test case that I'll commit. I'm working on a fix.
Andrew.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: FileHandleGcTest.java
URL: <http://gcc.gnu.org/pipermail/java/attachments/20011211/ac7bb8af/attachment.ksh>


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /