This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: System.gc() to close file descriptors (was RE: status of gcj's bo ehm collector?)
Andrew Haley writes:
> Tom Tromey writes:
> > >>>>> "Hans" == Boehm, Hans <hans_boehm@hp.com> writes:
> >
> > Hans> I looked at the gcj code a little more closely.
> > Hans> System.runFinalization() also seems to have two other problems:
> >
> > I think we should get in the habit of reporting all these sorts of
> > things to Gnats; we've dropped too many issues like this in the past.
> >
> > Andrew, are you still looking at this?
>
> Yes, but it's fairly low priority.
>
> I was thinking of running the finalizers in the finalization thread,
> but making System.runFinalization() wait until it has been done: it's
> easy enough to make finalization notify any waiting threads.
>
> I'm concerned about deadlock and race conditions, though. Comments
> welcome.
I looked at it some more. Hans's suggestion seems good, but it's
tricky to implement. It requires waiting until the finalization
thread has run, but AFAIK there isn't any way to guarantee that the
thread needing a file handle isn't holding some lock that prevents a
finalizer from running. In other words, the cure is worse than the
disease.
Also, I have talked to a Linux kernel engineer. He tells me that the
hard limit on file handles in Linux has been removed "because of
Java." I don't think that this is a reference to gcj in particular,
so other Java implementations have the same problem.
Andrew.