United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8021820 : Number of opened files used in select() is limited to 1024 [macosx]

Details
Type:
Bug
Submit Date:
2013-07-29
Status:
Resolved
Updated Date:
2013-08-29
Project Name:
JDK
Resolved Date:
2013-08-19
Component:
core-libs
OS:
os_x
Sub-Component:
java.net
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
8
Fixed Versions:

Related Reports
Backport:
Duplicate:
Relates:

Sub Tasks

Description
The number of opened files used in select() on MacOSX is limited to 1024 (FD_SETSIZE). 
The following  sequence can illustrate the problem:
1. Open 1023 files (use FileInputStream())
2. Create socket and try to read from it.
3. Get the following exception:
Exception in thread "main" java.net.SocketException: Invalid argument
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:150)
	at java.net.SocketInputStream.read(SocketInputStream.java:121)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
	at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:633)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:579)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:604)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1322)
	at SelectFdsLimit.main(SelectFdsLimit.java:86)

                                    

Comments
The MacOSx JDK uses the select() system call to wait for events on FDs (instead of poll() ). By default the number of file descriptors to select() on is limited to 1024. To remove this limit the D_DARWIN_UNLIMITED_SELECT flag should be used during compilation.
                                     
2013-07-29
The java.io code doesn't use select so we probably should be tracking this in another sub-component.
                                     
2013-07-29
The select is used only in java.net (Search for USE_SELECT macro). Based on this - suggesting 'java.net' sub-component.
                                     
2013-07-30
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/11ccaabdb2a8
User:  chegar
Date:  2013-08-19 09:48:17 +0000

                                     
2013-08-19
jdk8/tl changeset: http://hg.openjdk.java.net/jdk8/tl/rev/00dcfaa6bc01
                                     
2013-08-19
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/11ccaabdb2a8
User:  lana
Date:  2013-08-26 18:32:19 +0000

                                     
2013-08-26



Hardware and Software, Engineered to Work Together