JDK-8119730 : Animated GIFs cause memory leaks in javafx.scene.image.Image class
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 7u13
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-03-05
  • Updated: 2015-06-17
  • Resolved: 2013-03-05
Related Reports
Duplicate :  
Description
When I use animated gifs in the Image class, the memory won't be released.

Normal images work fine though.

See example:


import javafx.application.Application;
import javafx.scene.image.Image;
import javafx.stage.Stage;
 
public class TestApp2 extends Application {
    public static void main(String[] args) {
        Application.launch();
    }
 
    @Override
    public void start(Stage stage) throws Exception {
 
        for (int i = 0; i < 10000; i++) {
            new Image(getClass().getResourceAsStream("/animated.gif"));
        }
 
        System.gc();
        System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
    }
}

Comments
This is a duplicate of RT-19239
05-03-2013

You can test with this animated gif: http://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/200px-Rotating_earth_%28large%29.gif But every GIF should work. I get OutOfMemoryError pretty fast. With 20 iterations, my heap is 139004 KB!
05-03-2013