ProcessBuilder memory leak problem.

Posted on 2012-08-12
Last Modified: 2012-08-18
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??
Question by:gamjaradio
    LVL 86

    Assisted Solution

    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?

    Author Comment

    I want to ping an gateway to know my network is alive, which will be checked periodically.
    LVL 86

    Accepted Solution

    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)
    LVL 86

    Expert Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    hash value 2 29
    Fix45 challenge 15 66
    copyEndy  challenge 15 40
    Unable to start eclipse ? 17 49
    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
    This video teaches viewers about errors in exception handling.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now