Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java IOEXCEPTION:too many open files

 
tsaowe cao
Greenhorn
Posts: 5
IntelliJ IDE jQuery Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got these message when i trying to run a multithread program

java.io.IOException: Too many open files
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at cn.csdb.gsqcs.controller.DoWork.touchFileAndWrite(DoWork.java:319)
at cn.csdb.gsqcs.controller.DoWork.run(DoWork.java:44)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)


and these

java.io.IOException: Cannot run program "transeq": java.io.IOException: error=24, Too many open files
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at cn.csdb.gsqcs.controller.DoWork.run(DoWork.java:47)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.IOException: java.io.IOException: error=24, Too many open files
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)



it seems like i have opened too many file during the execution of my job,may be this is caused by not close the stream immediately,
but i really do close the stream ~can anyone do some help,any idea will be perfect~
 
jijun lx
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes , too many files are opened. It is the *nix os limited.
you can view the default number by execute :

change it by modify the /etc/security/limits.conf manually
add follows:


 
tsaowe cao
Greenhorn
Posts: 5
IntelliJ IDE jQuery Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does this operation need restart some service?
 
jijun lx
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, you'd better test it.
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post code snippet for faster assistance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!