stealthcopter / AndroidNetworkTools

Set of useful android network tools
Apache License 2.0
1.39k stars 282 forks source link

Native ping java Process streams not closed #53

Closed ravishekhar88 closed 4 years ago

ravishekhar88 commented 5 years ago

Hi,

In the PingNative::ping method, the process' input/output/error streams are not closed after completion.

While using this library in Android API level 23 (Marshmallow), it was leading to a spike in number of pipe file descriptors, eventually crashing the user App as the number of FDs were exceeding the allowed limit per process, if GC was not invoked at that instant. However, I did not face the same issue in Android API level 28 (Oreo).

Majki94 commented 5 years ago

This can be fixed by adding proc.destroy(); above every return in ping method. It is also good to close reader and buffer.

stealthcopter commented 4 years ago

This fix is added into the 0.4.4 build, thanks for your help!