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

JDK1.4.2: Memory leak on Runtime.exec() in linux

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Not an Issue
    • Affects Version/s: 1.4.2_19
    • Fix Version/s: None
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      linux_redhat_4.0

      Description

      The customer has experienced the native heap growth of java proces which run their app.
      From the results of test with sample app which simulates their actual app, they are confident that memory growth was caused by Runtime.exec() call, and they suspect it has a memory leak issue. They provided test app which calls Runtime.exec() repeatedly. And we are able to see the growth of java process size with that app in my lab machine.
      (1-2MB/day)

      Lab system for test:
        Host: s1lab228(10.14.1.228)
        SSH Login: guest/guest

      How to run sample app:
        [guest@s1lab228 ~]$ cd /users/guest/classes/
        [guest@s1lab228 ~]$ which java
        [guest@s1lab228 ~]$ ulimit -n 65535
        /net/s1lab66/vmware/java/linux_i586/j2sdk1.4.2_12/bin/java
        [guest@s1lab228 classes]$ java -Xms16m -Xmx16m -Xloggc:gc.log -XX:+PrintGCDetails RuntimeTest

      Sample App Source:
         /net/cores.central/cores/72113010/task/classes/CmdPing.java
         /net/cores.central/cores/72113010/task/classes/DummyThread.java
         /net/cores.central/cores/72113010/task/classes/RuntimeTest.java

         * This sample app repeatedly invokes "ping -c 2 localhsot" using Runtime.exec().


      ##
      ## How to confirm the growth of the process memory.
      ##

      Since new threads are created/exited frequently, chage of process size is large.
      So we only focus on the process size when thread number is minimum.(=309)

        $ ps -p 32733 -o pid,rss,vsz,nlwp
        PID RSS VSZ NLWP
        32733 22500 355636 309
          : ^^^^^^
          :
        $ ps -p 32733 -o pid,rss,vsz,nlwp
        32733 32372 362344 309
                    ^^^^^^ Compare VSZ when NLWP is 309!

        I saw 1-2 MB of increase in VSZ per day.

      ##
      ## Logs
      ##

      The sample program is now running on the system above.
      You can see the ps output and pmap outputs.

        [guest@s1lab228 ~]$ cd /users/guest/logs
         pmap.32733.* ... pmap output files every 15mins
         ps.32733.091221-12:01:12.log ... ps output every 1 sec

         The process was just started. (12/21 12:00 JST)
         And the ps and pmap are captured using shell scripts.

      ##
      ## Other info
      ##

      I was able to see the same symptom of process memory size with J2SE1.4.2u19 and JFB1.4.2u24.
      J2SE1.4.2u19 and JFB1.4.2u24 are also available on lab system.

         J2SE1.4.2u19: /usr/java/j2sdk1.4.2_19/
         JFB1.1.2u24: /net/s1lab66/vmware/java/linux_i586/j2sdkfb1.4.2_24/



      We have suggested to customer to put the following in the above testing code

      public class CmdPing extends Thread {
      :
      ps.waitFor();
      ps.getErrorStream().close(); // Added
      ps.getOutputStream().close(); // Added
      } catch (Exception e) {

      but the problem still persists.

      Moreover, the same code running on solaris doesn't show any problem.

        Attachments

          Activity

            People

            • Assignee:
              kevinw Kevin Walls
              Reporter:
              helai Herrick Lai (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: