Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby-OSSL 0.7.1
-
Fix Version/s: JRuby-OSSL 0.7.2
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
SSLSocket currently opens three selectors immediately on creation, registering selection keys with each right away. This was probably done to avoid reconstructing the selectors for each read operation. This is unfortunately rather inefficient; the three selectors each consume three file descriptors, and because they all register selection keys immediately they don't get collected until the sun.nio.ch.SocketChannelImpl they're associated with gets finalized. Under heavy load, with many sockets created and thrown away, this can quickly eat up all available file descriptors for a process.
I'm working on a fix at the moment; I will simply accept the hit of doing a Selector.open each time a selection operation is required, which will reduce the amount of descriptors left hanging by 90%. The remaining descriptor (that for the socket itself) will eventually get collected.
I'll also look into whether we can forcibly clean up the socket in case of a dropped connection.
Issue Links
- is duplicated by
-
JRUBY-5015
Too many open files when using imap over ssl
-
I pushed the selector fix to jruby-ossl in dc45408. Looking at the socket cleanup now.