Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1162
  • Last Modified:

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??
0
gamjaradio
Asked:
gamjaradio
  • 3
2 Solutions
 
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:
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:
:)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now