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

Thread.stop() leaks memory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 1.2.0
    • 1.1.4, 1.1.5
    • hotspot
    • 1.2beta4
    • x86
    • solaris_2.6, windows_95



      Name: joT67522 Date: 11/26/97


      Compile ThreadTest.java and run with
      parameters such as:

      java -mx500k -ms500k ThreadTest

      It will eventually die with an OutOfMemoryError.
      If you remove the call to "thread.stop()"
      from the code, it will run happily for quite
      a long time. Each call to stop() seems to
      leak memory until the JVM finally dies.

      This failure occurs with both with java
      1.1.3 (as supplied with Solaris 2.6) and
      with JDK 1.1.4 with the native threads pack.
      Using native or green threads does not seem
      to matter. Using the JIT or not does not
      make a difference either.
      The program always dies.

      This is a serious
      problem for server programming --- we're building
      a service for a major customer using the Java
      Web Server and we need the ability to create
      threads on the fly and kill them after a
      specified timeout.

      ------------------------
      public class ThreadTest
      {
        public static void main(String[] args)
        {
          while (true) {
            Thread thread = new Thread() {
      public void run()
      {
      try {
      sleep(10);
      } catch (InterruptedException e) {
      }
      }
            };
            thread.start();
            thread.stop();

            try {
      Thread.sleep(10);
            } catch (InterruptedException e) {
            }
          }
        }
      }
      ------------------------
      (Review ID: 20933)
      ======================================================================

            sliangsunw Sheng Liang (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: