By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,247 Members | 871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,247 IT Pros & Developers. It's quick & easy.

java.io.Exception: Too many open files on sun OS 5.6

P: n/a
I'm operating on sun OS 5.6
I ping a host every 10 seconds to get knowlegde wheather it is running
or not. After about one and a half hour I get this Exception:
java.io.IOException: Too many open files
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:54)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:546)
at java.lang.Runtime.exec(Runtime.java:413)
at java.lang.Runtime.exec(Runtime.java:356)
at java.lang.Runtime.exec(Runtime.java:320)
at de.optimare.VRX8100.MainControl.pingRecorder(MainC ontrol.java:226)
.... and so on.

I set rlim_fd_max = 1024 in /etc/system
I tried to set the ulimit -n 1024 in my script

but it had no effect.

Here is my code: The pingRecorder is called every 10 seconds from a
swing.Timer.
runtime is the Runtime.getRuntime().

// used on unix system
private void pingRecorder() {
logDate = new Date();

try {
ping = runtime.exec(pingPath);
ping.waitFor();
exitValue = ping.exitValue();
switch (exitValue) {
case 0:
// stop the ping timer
if (pingTimer != null) {
pingTimer.stop();
}

if (! processIsInitialized) {
System.out.println(logDate.toString() + " Recorder alive. Now
wait " + initialWaitTime/1000 + " seconds to initialize");
//wait for recorder is booting
Thread.sleep(initialWaitTime);
// now init the VRX8100 process!
initProcess();
}

break;

case 1:
System.out.println(logDate.toString() + " Recorder off.
Memory: " + runtime.totalMemory());
break;
default:
System.out.println(logDate.toString() + " Recorder off.
Memory: " + runtime.totalMemory());
break;
}

} catch (IOException io) {
io.printStackTrace();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}

I would be very happy if anyone knows about anything due to this
problem.
Is it a specific sun problem? Is it possible to control the number of
open files by Java?
Many thanks for any help
Gert
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Gert Schumann wrote:
I'm operating on sun OS 5.6
I ping a host every 10 seconds to get knowlegde wheather it is running
or not. After about one and a half hour I get this Exception:
java.io.IOException: Too many open files
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:54)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:546)
at java.lang.Runtime.exec(Runtime.java:413)
at java.lang.Runtime.exec(Runtime.java:356)
at java.lang.Runtime.exec(Runtime.java:320)
at de.optimare.VRX8100.MainControl.pingRecorder(MainC ontrol.java:226)
... and so on.


I would be very happy if anyone knows about anything due to this
problem.
Is it a specific sun problem? Is it possible to control the number of
open files by Java?


Gert,

I suspect the problem is that the call to Runtime.exec() creates stream
handles for the standard input, output and error streams. You should
make sure to close these streams in your code. (Capture the Process
object returned from Runtime.exec() to get access to these streams.)

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 17 '05 #2

P: n/a
Liz

"Gert Schumann" <ge**********@web.de> wrote in message
news:e6**************************@posting.google.c om...
I'm operating on sun OS 5.6
I ping a host every 10 seconds to get knowlegde wheather it is running
or not. After about one and a half hour I get this Exception:
java.io.IOException: Too many open files
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:54)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:546)
at java.lang.Runtime.exec(Runtime.java:413)
at java.lang.Runtime.exec(Runtime.java:356)
at java.lang.Runtime.exec(Runtime.java:320)
at de.optimare.VRX8100.MainControl.pingRecorder(MainC ontrol.java:226)
... and so on.

I set rlim_fd_max = 1024 in /etc/system
I tried to set the ulimit -n 1024 in my script

but it had no effect.

Here is my code: The pingRecorder is called every 10 seconds from a
swing.Timer.
runtime is the Runtime.getRuntime().

// used on unix system
private void pingRecorder() {
logDate = new Date();

try {
ping = runtime.exec(pingPath);
ping.waitFor();
exitValue = ping.exitValue();
switch (exitValue) {
case 0:
// stop the ping timer
if (pingTimer != null) {
pingTimer.stop();
}

if (! processIsInitialized) {
System.out.println(logDate.toString() + " Recorder alive. Now
wait " + initialWaitTime/1000 + " seconds to initialize");
//wait for recorder is booting
Thread.sleep(initialWaitTime);
// now init the VRX8100 process!
initProcess();
}

break;

case 1:
System.out.println(logDate.toString() + " Recorder off.
Memory: " + runtime.totalMemory());
break;
default:
System.out.println(logDate.toString() + " Recorder off.
Memory: " + runtime.totalMemory());
break;
}

} catch (IOException io) {
io.printStackTrace();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}

I would be very happy if anyone knows about anything due to this
problem.
Is it a specific sun problem? Is it possible to control the number of
open files by Java?
Many thanks for any help
Gert


I have seen the 'too many open files' message in various
OS and languages. Seems like setting parameters doesn't
usually work for me so I just have to be careful to close
files when I am done with them.
Jul 17 '05 #3

P: n/a
>
Gert,

I suspect the problem is that the call to Runtime.exec() creates stream
handles for the standard input, output and error streams. You should
make sure to close these streams in your code. (Capture the Process
object returned from Runtime.exec() to get access to these streams.)

HTH,
Ray


Dear Ray,
Thanks, you solved the problem. It's working fine now!
Gert
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.