Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Maximum simultaneous opened files in a java thread on linux 1.4.20

843811Mar 11 2004 — edited Mar 12 2004
Hello,

It seems like a maximum of 1024 files can be opened by a processus on linux (in java, a thread is a linux processus).
Is it possible to change this value, or has it been set at the JVM compilation?

I created a nio server, and one thread is to manage thousands of connections. For the moment I can't pass 1010 connections.

As a fast test, I created the following source :

public class MaxOpenedFilesTest {

/** Creates a new instance of MaxOpenedFilesTest */
public MaxOpenedFilesTest() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
File f = new File("/home/greg/a.out");

FileInputStream[] stream = new FileInputStream[2000];

try {
for (int i=0; i<stream.length; i++) {
stream[i] = new FileInputStream(f);
System.out.println(i+" files opened");
}
}
catch (Exception e) {
System.out.println("ERROR : "+e);
e.printStackTrace();
}
}
}

This test throws an IOException at 1019 files opened : Too many opened files...

I have tested a lot of things. I even recompiled the linux kernel. Changed the NR_OPEN, OPEN_MAX, __FD_SETSIZE, etc... Still don't work.

I havve set the global maximum file descriptor to 65536. It works. But for one thread, I can't have more than 1019 file descriptors (must be the 1024 initial limit defined by the kernel)...

Could somebody help.
It would be great.
Thank you.
Gr�goire.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2004
Added on Mar 11 2004
5 comments
226 views