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

ImageView / Image - Memory Leak

XMLWordPrintable

      I've seen a memory leak that I confirmed also under JavaFX 2.1.0-beta-b19 on top of Java 1.6. Basically I have a JavaFX application in which I display through an ImageView object a different JPEG image every 30 seconds. The relevant code looks like,

      inputStream = ClassLoader.getSystemResourceAsStream(...
      imageView.setImage(new Image(inputStream));
      ...
      inputStream.close();

      Unfortunately, when running the application with the NetBeans memory profiler it shows that the image bytes are never garbage collected resulting in a significant memory leak. Every time an image is loaded NetBeans reports that the number of allocated objects of the class 'sun.net.www.protocol.file.FileURLConnection' increases by one, also the image data continuously increase in memory throughout the application execution time as byte[] data.

      I have also attached a quick test application (ImageTest.java) that reproduces the described memory leak.

        1. ImageTest.java
          2 kB
          Christos Bohoris
        2. RT-20757-screen-1.png
          398 kB
          Christos Bohoris
        3. RT-20757-screen-2.png
          92 kB
          Christos Bohoris

            psafrata Pavel Ĺ afrata
            cbohorisjfx Christos Bohoris (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: