"java.io.IOException: Too many open files" rlim_fd_cur set to max

C

Cathy Hui

I am getting the "java.io.IOException: Too many open files" error when
running some program on a Solaris 8. Pls note, I have already set
ulimit to max. How can I avoid this problem? Thanks in advance for
answering my question.

Here is the output from "uname -a":

SunOS ax-pb2 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-5_10

Here is what I have on the /etc/system:

set rlim_fd_cur = 4096
set rlim_fd_max = 4096
 
R

Rhino

Cathy Hui said:
I am getting the "java.io.IOException: Too many open files" error when
running some program on a Solaris 8. Pls note, I have already set
ulimit to max. How can I avoid this problem? Thanks in advance for
answering my question.
Open fewer files?

Close files before you open new ones?

Do you really need 4096 files open at the same time??

Rhino
 
W

Wiseguy

Cathy Hui said:
How can I avoid this problem?

Don't open so many files at once. :^P

Seriously, to get any useful answer to this questions you need to tell us
how many files you are openning and maybe post some example code (as long
as it's not too long).

A description of what exactly you are trying to do would not hurt.
 
D

Dotty

Cathy Hui said:
I am getting the "java.io.IOException: Too many open files" error when
running some program on a Solaris 8. Pls note, I have already set
ulimit to max. How can I avoid this problem? Thanks in advance for
answering my question.

Here is the output from "uname -a":

SunOS ax-pb2 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-5_10

Here is what I have on the /etc/system:

set rlim_fd_cur = 4096
set rlim_fd_max = 4096

Gee, how about closing some files.
 
C

Cathy Hui

The script processes one profile each time. And each profile has at
least 2 files to process (just rename them, it will take just
milli-seconds). There are 1276 profiles on this process.

Here is the code, pls advise. thanks!

===========================================

private int moveConfFiles(String pPath, String workPath,
boolean sign) {
File dir = new File(workPath);
File vFile = null;
if (dir.exists()) {
File[] fileList = dir.listFiles();
int numFile = fileList.length;
if (numFile > 0) {
for (int i = 0; i < numFile; i++) {
if (fileList == null ||
(!fileList.isFile())) {
return MOVE_FAILED;
}
vFile = new File(pPath +
fileList.getName());
if (vFile != null && vFile.exists()) {
vFile.delete();
}
if (!fileList.renameTo(vFile)) {
return MOVE_FAILED;
}

}
}
}
return MOVE_SUCCESSFUL;
}
 
C

Cathy Hui

Correction from the last mesg:

i.e. each profile has at least 4 files to process
 
W

Wiseguy

Cathy Hui said:
The script processes one profile each time. And each profile has at
least 2 files to process (just rename them, it will take just
milli-seconds). There are 1276 profiles on this process.

Here is the code, pls advise. thanks!

===========================================

private int moveConfFiles(String pPath, String workPath,
boolean sign) {
File dir = new File(workPath);
File vFile = null;
if (dir.exists()) {
File[] fileList = dir.listFiles();
int numFile = fileList.length;
if (numFile > 0) {
for (int i = 0; i < numFile; i++) {
if (fileList == null ||
(!fileList.isFile())) {
return MOVE_FAILED;
}
vFile = new File(pPath +
fileList.getName());
if (vFile != null && vFile.exists()) {
vFile.delete();
}
if (!fileList.renameTo(vFile)) {
return MOVE_FAILED;
}

}
}
}
return MOVE_SUCCESSFUL;
}


my only suggestion is to save dir.listFiles() as an array of Strings
instead of an array of Files. Then convert the String representation
back to File when you actually need it. I suspect that File [] is
causing you to run out of file handles. You might also want to
evaluate the scope of vFile and see if you can figure out a way to
force object destruction when the old object reference is no longer
needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top