Java .io.ioexception too many open files




















Viewed k times. Improve this question. Put a comment in the function that will open the files and verify that you are only opening each one one time.

How do you know that this error occurs because of one of these 19? Java itself or the framework you're using might be opening files. Perhaps you are opening them inside a loop, so it happens repeatedly. If you don't close the files yourself and just leave it to the garbage-collector to clean it up for you then it will take a long time for that to happen.

In the meantime, you're busy opening more files and before you know it, you've hit the limit. Add a comment. Active Oldest Votes. Your Java application must be exceeding the per-process file descriptor limit. Improve this answer. Stephen C Stephen C k 90 90 gold badges silver badges bronze badges. I would recommend to use IOUtils. I would use that too. But I wouldn't recommend adding that dependency JUST to get a method that you can write yourself in 2 minutes. Indeed, in I would strongly recommend using try with resources ; i.

If you are still using Java 6 or earlier, you should upgrade. Java 6 has been out of maintenance for 4 years now. As of 2. Please use the try-with-resources statement or handle suppressed exceptions manually.

As of Java 7, you shouldn't need to close explicitly anymore. The IOUtils deprecation is simply trying to get to do things in a more modern way Stephen C k 90 90 gold badges silver badges bronze badges. It only avoids the problem until your application hits the new higher limit. IMO, this is not a good solution. Falmarri Falmarri If he indeed opens 19 files, and has an array with the file descriptors, then he should be fine, but I think he is actually opening up more than he thinks he does.

I guarantee windows has a file descriptor limit. It just may default to — Falmarri. I hope this helps someone. Javadoc says: The parent process uses these streams to feed input to and get output from the subprocess.

Improve this answer. This is the right answer that actually contains useful information. You don't need to destroy the process if waitFor has succeeded. The process has already exited. This might get you up to 2 months of run-time! This is a band-aid at best. You've re-iterated the symptom but not a real cure.

This at least can solve our problem. The application 3rd Party is opening more than There is NO leak, but just the limit it too low. Setting the limit to as suggested in this article.

It looks like the problem is gone. The default limit can be too low for large Java applications. Community Bot 1 1 1 silver badge. Rami Jaamour Rami Jaamour 2 2 silver badges 2 2 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. First, get the PID of the java application that is throwing this error message.

In the following example, is the PID. Next, count how many files this particular PID has opened.



0コメント

  • 1000 / 1000