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

Test MemoryLeak.java seems not to test what it is supposed to test

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • core-libs
    • None

      test/jdk/java/lang/ThreadLocal/MemoryLeak.java introduced in https://bugs.openjdk.org/browse/JDK-4414045 loops 1.1 million times. When it was created, it was probably correct, but with modern heap sizes my thinking is that there will never be a shortage of memory and if we would leak, we would not notice it as we have enough heap size to leak far more than 1.1 million objects. I think the test ought to be started with a limited heap size, and maybe more iterations

      Maybe something like:
      ```
      /*
       * @test
       * @bug 4414045
       * @summary Tests to see that memory leak no longer exists.
       * @run main/othervm -Xmx60m MemoryLeak
       */

      public class MemoryLeak {
          public static void main(String[] args) {
              for (int i = 0; i < 30_000_000; i++) {
                  ThreadLocal t = new ThreadLocal();
                  t.set(new Object());
                  t.set(null);
              }
          }
      }
      ```

            Unassigned Unassigned
            lkorinth Leo Korinth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: