angelj2188 / roottools

Automatically exported from code.google.com/p/roottools
0 stars 0 forks source link

Streams are not closed which leads to "too many open files errors" #38

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a small app, which loops over a shell command for several times
2. After some iterations the programm will abort with a "Too many open files" 
exception

The main point is, that each Process has 3 streams associated with it (input, 
output and error). All three streams need to be closed individually. As far as 
I can see the currently committed code 
(https://code.google.com/p/roottools/source/browse/trunk/Developmental/RootTools
_sdk3_generic/src/com/stericson/RootTools/execution/Shell.java) the streams are 
not closed.

proc.destroy() may not close all the streams. It says so in the documentation, 
but here someone says it is OS dependend: 
http://stackoverflow.com/questions/15956452/troubleshooting-too-many-files-open-
with-lsof (second comment on first answer)

See also 
http://mark.koli.ch/2011/01/leaky-pipes-remember-to-close-your-streams-when-usin
g-javas-runtimegetruntimeexec.html for reference (although I would not use 
IOUtils just for that).

I am using v3-beta, release on June 30th. Please provide an updated JAR, when 
the issue is fixed.

Original issue reported on code.google.com by tob...@schulz-hess.de on 4 Jul 2013 at 8:34

GoogleCodeExporter commented 8 years ago
I have created a patch to fix this issue. Please review it.

(Sorry, my code formatter also reformatted some comments.)

Original comment by tob...@schulz-hess.de on 4 Jul 2013 at 9:37

Attachments:

GoogleCodeExporter commented 8 years ago
I have addressed this.

Thanks for catching this and pointing it out :)

https://code.google.com/p/roottools/downloads - new version has been posted

Original comment by Stericso...@gmail.com on 4 Jul 2013 at 2:57