Link to home
Start Free TrialLog in
Avatar of Buffon
BuffonFlag for Israel

asked on

Too many open files

I got exceptions like:
java.net.SocketException: Too many open files
java.net.PlainSocketImpl.socketAccept(Native Method)
java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
java.net.ServerSocket.implAccept(ServerSocket.java:450)
java.net.ServerSocket.accept(ServerSocket.java:421)

or

java.io.IOException: java.io.IOException: Too many open files
java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
java.lang.ProcessImpl.start(ProcessImpl.java:65)
java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
java.lang.Runtime.exec(Runtime.java:591)
java.lang.Runtime.exec(Runtime.java:429)
java.lang.Runtime.exec(Runtime.java:326)

or

java.io.IOException: Too many open files
sun.nio.ch.IOUtil.initPipe(Native Method)
sun.nio.ch.PollSelectorImpl.<init>(PollSelectorImpl.java:40)
sun.nio.ch.PollSelectorProvider.openSelector(PollSelectorProvider.java:18)
java.nio.channels.Selector.open(Selector.java:209)


after those, which happened in different threads my application got stuck. What is this? Some kind of unix/linux problems or java? What can be done?
Avatar of hoomanv
hoomanv
Flag of Canada image

This seems to be because you open FileInputStreams, but don't close them!
You should explicitly close them
Avatar of Buffon

ASKER

all the filestreams are closed explicitly in the end of each thread. I think its because I have many open sockets and files concurrently may be? What is the limit?
ASKER CERTIFIED SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Buffon

ASKER

ok, it seems as right direction. I will check it ASAP and will be back to you. 10x.
Avatar of Buffon

ASKER

sorry I was away for a long time :( currently I am trying to install lsof utility:
https://www.experts-exchange.com/questions/22045878/lsof.html