There is a java program which read files from a folder, do some processing and write output files in another folder. It ran for 4 hours and produced few files but then failed after throwing following error:
"too many files"
Then I modified the program to close everything (BufferReader and BufferWriter) and started the process again. But this time process failed just after starting by throwing following error:
java.io.FileNotFoundException: <file> (Too many open files)
Then i tried running lsof and searched for the process which is having most no of open files. I realized it is NetworkManager. But I was not sure whether i should kill that process or not. So I restarted the machine. Even after that when I ran java program, I still got the same error.
In worst case it might be possible that my code is still having some leaks in terms of not closing everything, but still it is failing now just after starting the process. So I have a feeling that something is lying in system from previous run. Also If I start same process in some other machine, it runs for hours before failing.