Reputation: 533
I am trying to diagnose a resources leak and want to know if ALL the streams in the Process created by Runtim.exec need to be close.
I have looked through the documentation and see no mention that they need to be explicitly closed.
If they do not it would be very helpful.
Upvotes: 0
Views: 86
Reputation: 3638
Yes, the streams returned by Runtime.exec
should be closed to avoid resource leaks.
From the process docs
The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.
The subprocess is not killed when there are no more references to the Process object, but rather the subprocess continues executing asynchronously.
Upvotes: 1