Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4058038

JDK 1.1.1/1.1.2 Runtime.exec() leaks memory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1.2
    • hotspot
    • sparc
    • solaris_2.5.1



      The code below ( procs.java ) exhibits memory leak at runtime.
      The problem does not occur with JDK1.1FCS version.

      File: procs.java

      import java.io.IOException;

      class procs {
          private Runtime _runtime;
          private String _cmdline;

          public procs (String cmdline)
          {
              _runtime = Runtime.getRuntime();
              _cmdline = cmdline;
          }

          public void executeCmdline()
          {
              Process p;
              int retval;

              try {
                  p = _runtime.exec(_cmdline);
              }
              catch (SecurityException se) {
                  System.err.println(se);
                  return;
              }
              catch (IOException ioe) {
                  System.err.println(ioe);
                  return;
              }
              try {
                  p.waitFor();
              }
              catch (InterruptedException ie) {
                  System.err.println(ie);
              }
              try {
                  retval = p.exitValue();
                  if (retval != 0) {
                      System.err.println("ERROR: Process " + p + " returned "
      + retval);
                  }
              }
              catch (IllegalThreadStateException itse) {
                  System.err.println(itse);
              }
          }

          public static void main(String[] args)
          {
              procs p1, p2;

              p1 = new procs("/usr/bin/date");
              while (true) {
                  p1.executeCmdline();
              }
          }
          
      }

      -----------------------

      Using jdk.1-1fcs


      maria: java -version
      java version "1.0.2dp:12/18/96-17:52"
      maria: java procs

      maria: /usr/ucb/ps -auxw | grep maria
      maria 24302 10.6 3.4 3056 2064 pts/0 S 18:23:00 0:06 /usr/dist/share/jws,v1.0a/5bin.sun4/JDK/bin/../bin/sparc/java procs
      maria 24213 0.0 1.7 1176 1040 pts/0 S 18:20:02 0:00 -csh
      maria 24247 0.0 1.7 1176 1040 pts/1 S 18:21:08 0:00 -csh
      maria 25349 0.0 0.3 152 152 pts/0 R 18:23:52 0:00 /usr/bin/date
      maria 25350 0.0 1.7 1176 1040 pts/1 R 18:23:52 0:00 -csh
      maria: !!
      /usr/ucb/ps -auxw | grep maria
      maria 24302 11.0 3.4 3056 2064 pts/0 R 18:23:00 0:07 /usr/dist/share/jws,v1.0a/5bin.sun4/JDK/bin/../bin/sparc/java procs
      maria 24213 0.0 1.7 1176 1040 pts/0 S 18:20:02 0:00 -csh
      maria 24247 0.0 1.7 1176 1040 pts/1 R 18:21:08 0:00 -csh
      maria 25513 0.0 0.3 152 152 pts/0 R 18:24:00 0:00 /usr/bin/date
      maria: !!
      /usr/ucb/ps -auxw | grep maria
      maria 24302 11.2 3.4 3056 2064 pts/0 S 18:23:00 0:07 /usr/dist/share/jws,v1.0a/5bin.sun4/JDK/bin/../bin/sparc/java procs
      maria 25654 0.1 0.3 192 192 pts/0 R 18:24:07 0:00 /usr/bin/date
      maria 24213 0.0 1.7 1176 1040 pts/0 S 18:20:02 0:00 -csh
      maria 24247 0.0 1.7 1176 1040 pts/1 R 18:21:08 0:00 -csh
      maria: !!
      /usr/ucb/ps -auxw | grep maria
      maria 24302 11.7 3.4 3056 2064 pts/0 S 18:23:00 0:14 /usr/dist/share/jws,v1.0a/5bin.sun4/JDK/bin/../bin/sparc/java procs
      maria 26897 0.1 0.7 784 392 pts/0 R 18:25:08 0:00 /usr/bin/date
      maria 24213 0.0 1.7 1176 1040 pts/0 S 18:20:02 0:00 -csh
      maria 24247 0.0 1.7 1176 1040 pts/1 R 18:21:08 0:00 -csh

      ------------------------

      Using jdk-1.1.2 ( same result using jdk-1.1.1)

      maria: java -version
      java version "1.1.2"
      maria: javac procs.java
      maria: java procs

      maria: !!
      /usr/ucb/ps -auxw | grep maria
      maria 28966 12.6 5.7 4144 3512 pts/0 S 18:31:46 0:03 /net/jakarta.corp/export2/Java/jdk_1.1.2/jdk1.1.2/bin/../bin/sparc/gre
      maria 29328 0.1 0.7 832 440 pts/1 R 18:32:00 0:00 grep maria
      maria 24213 0.0 1.7 1176 1056 pts/0 S 18:20:02 0:00 -csh
      maria 24247 0.0 1.7 1176 1040 pts/1 S 18:21:08 0:00 -csh
      maria 29326 0.0 0.7 816 424 pts/0 R 18:32:00 0:00 /usr/bin/date
      maria: !!
      /usr/ucb/ps -auxw | grep maria
      maria 28966 15.7 5.7 4144 3512 pts/0 R 18:31:46 0:05 /net/jakarta.corp/export2/Java/jdk_1.1.2/jdk1.1.2/bin/../bin/sparc/gre
      maria 29479 0.1 1.2 832 712 pts/1 S 18:32:06 0:00 grep maria
      maria 24213 0.0 1.7 1176 1056 pts/0 S 18:20:02 0:00 -csh
      maria 24247 0.0 1.7 1176 1040 pts/1 S 18:21:08 0:00 -csh
      maria 29477 0.0 1.1 4144 640 pts/0 S 18:32:06 0:00 /net/jakarta.corp/export2/Java/jdk_1.1.2/jdk1.1.2/bin/../bin/sparc/gre
      maria: !!
      /usr/ucb/ps -auxw | grep maria
      maria 28966 17.9 5.7 4152 3520 pts/0 R 18:31:46 0:06 /net/jakarta.corp/export2/Java/jdk_1.1.2/jdk1.1.2/bin/../bin/sparc/gre
      maria 29658 0.1 1.2 832 712 pts/1 S 18:32:13 0:00 grep maria
      maria 24213 0.0 1.7 1176 1056 pts/0 S 18:20:02 0:00 -csh
      maria 24247 0.0 1.7 1176 1040 pts/1 S 18:21:08 0:00 -csh
      maria 29656 0.0 0.6 4152 368 pts/0 R 18:32:13 0:00 /net/jakarta.corp/export2/Java/jdk_1.1.2/jdk1.1.2/bin/../bin/sparc/gre

            apalanissunw Anand Palaniswamy (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: