Thanks. Calling Runtime.exec() without closing the streams was the culprit.
The problem is fixed now.
Regards,
Faro
Gordon Beaton wrote:
> On Tue, 04 Jan 2005 21:39:50 +0530, Firdousi Farozan wrote:
>
>>In a java process (that uses JNI and socket communications), I get
>>"Too many open files" error. This is on Solaris.
>
>
> Don't crosspost to so many newsgroups. Followup set.
>
> Obviously you haven't closed all the streams you've opened in your
> code. The solution is simple: you need to explicitely close every
> single stream when you are done with it, always. You can't rely on
> finalization to do this for you, the garbage collector is not able to
> recover external resources like file descriptors in a timely manner.
>
> Note that not all pipes are named pipes. If you had opened named
> pipes, I would expect that you would see their names in the output of
> lsof, and you should be able to find their use in your code.
>
> The fact that there are as many as 350 open descriptors seems to
> indicate that you are doing something repeatedly that involves one or
> more open streams. Does that ring a bell?
>
> It is not clear from the information you've posted whether your
> program crashed in Java or in a native method. If the crash occurred
> in Java, where is the text of the exception? It should tell you what
> the application was attempting to do that would have caused the
> descriptor limit to be exceeded.
>
> If it crashes in native code, check return values of all your system
> calls, and note where it fails (and take additional system or language
> questions to a more appropriate newsgroup).
>
> For debugging, you can use ulimit to set the descriptor limit much
> *lower* (to 5 or 10) so the crash occurs sooner. Choose various small
> limits until you find the real source of the problem.
>
> Since your descriptors are all pipes, I'll hazard a guess that you've
> been invoking Runtime.exec() without closing the three streams
> associated with the resulting Process object after the child process
> is finished.
>
> /gordon
>
|