ProcessBuilder memory leak problem.

ProcessBuilder pb = null;
            Process proc = null;
            try {

                  pb = new ProcessBuilder("cmd", "/c", "ping");
                       proc = pb.redirectErrorStream(true).start();
   ******// the problem just above. Whenever calling 'pb.redirectErrorStream(true).start();' using memory goes up..
So ultimately my program is shutting down abruptely.

How can I solve this out??
Who is Participating?
Is that actually your goal? Bear in mind that might possibly give you a false positive if your real goal involves connecting to an address on the Web (say)
You need to consume the output stream of the process properly in a separate thread. Study this carefully:

What's the goal of that code btw?
gamjaradioAuthor Commented:
I want to ping an gateway to know my network is alive, which will be checked periodically.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.