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

Image object hangs on to byte[]

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: fx2.0.2, fx2.1
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:
    • Environment:

      Java 1.6_30 (32bit), JavaFX 2.0.2 (32bit) and 2.1b17 (32bit), Windows 7 (64bit)

      Description

      I have some code that loads and displays multiple images one at a time. I am creating an Image from an input stream that represents an animated gif.

      InputStream inputStream = new ByteArrayInputStream(animatedGifByteArray);
      Image image = new Image(inputStream);

      After the image is no longer used and discarded, the byte[] is never garbage collected. I don't even need to set the image in an ImageView.. the code above is enough to cause the issue.

      VisualVM shows that the QuantumToolkit.animationRunnable field is the nearest GC root.

      I've tried it in 2.0.2 and 2.1 b17.

      It only appears to happen with animated gif files. Regular gif files don't seem to cause the problem.

      Here's a simple code example. With a 70k animated gif file ("animated.gif"), this code will cause an OutOfMemoryError at about the 60th image (using JREs default max heap size).

      I'm using JavaFX 2.1 b17 with JRE 1.6_30 on Windows 7.

      public class ImageLeakTest extends Application {
      public void start(Stage stage) throws Exception {
      for (int i = 0; i < 100; i++) {
      new Image("C:/animated.gif");

      Thread.sleep(500);
      }
      }

      public static void main(String[] args) {
      Application.Launch(args);
      }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jandrese Joe Andresen (Inactive)
                Reporter:
                cbridgersjfx Chris Bridgers (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: