It just occurred to me that our map from numeric file descriptors to open channels doesn't need to be weak, and indeed making it weak could actualy be *incorrect*.

In libc, if you open a file, you get a file descriptor as an integer. That descriptor is guaranteed to be kept open for you until the process terminates or you close the fd yourself. So our allowing the channel associated with a numeric fd to possibly GC and finalize breaks that model.

Also, the case we're trying to prevent with a weak descriptor map--that of an application spinning up lots of IO objects and never closing them--would be a leak under libc as well; you'd quickly reach an open fd limit before garbage collection kicks in.

It seems like what we really want here is for the ChannelDescriptor associated with the fd to only unregister itself on GC or close, and have the map be hard references. This allows e.g. sysopen to work correctly all the time (rather than having a separate hard-referencing map as we do now) and probably wouldn't lead to any more descriptor leakage than we have today, since the expectation is that all channels are being properly closed to begin with. And the finalization of ChannelDescriptor would help ensure the map gets cleaned up if an application really is leaking descriptors.

Does this make sense?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to