ProcessBuilder memory leak problem.

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

                  pb = new ProcessBuilder("cmd", "/c", "ping 192.168.1.1");
                       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??
gamjaradioAsked:
Who is Participating?
 
CEHJCommented:
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)
0
 
CEHJCommented:
You need to consume the output stream of the process properly in a separate thread. Study this carefully:

http://technojeeves.com/joomla/index.php/free/52-runtimeexec

What's the goal of that code btw?
0
 
gamjaradioAuthor Commented:
I want to ping an gateway to know my network is alive, which will be checked periodically.
0
 
CEHJCommented:
:)
0
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.