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

Native memory leak with jar-file reading

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 x64; Solaris

      A DESCRIPTION OF THE PROBLEM :
      Native memory leak was found using simple example. Native heap increases all time during execution of source code.
      There are several threads with getting jar enties (see source code for details).
      The issue is reproducible with Java6&Java7, x32&x64. Most of measurements were done using Java 7 u9. However the issue exists for Java 7 u25.
      Using Java 7 x32 I have following results:
      At the start of application it takes about 50Mb of native heap. After 60 minutes it takes about 500Mb already.
      With Java x64 at the start it takes about 600Mb and after 60 minutes it takes about 2Gb.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Main2 {

        public void test(File file) throws Exception {

          JarFile jarFile = null;
          Enumeration<JarEntry> enumeration = null;
          try {
            jarFile = new JarFile(file);
            enumeration = jarFile.entries();
            do {
              if (!enumeration.hasMoreElements()) {
                break;
              }
              ZipEntry zipentry = enumeration.nextElement();
            } while (true);
          } finally {
            jarFile.close();
          }
        }

        public static void main(String... s) throws Exception {

          final Main2 r = new Main2();
          final File jarFile = new File( " c:\\tmp\\test.jar " );

          for (int i = 0; i < 10; i++) {
            Thread t = new Thread(new Runnable() {

              @Override
              public void run() {
                while (true) {
                  try {
                    r.test(jarFile);
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                }
              }
            });

            t.start();
          }
        }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            sherman Xueming Shen
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: