title: High memory consumption by an Image
body: <p>Below is a sample code. Where it loads 6 Images and displays them in a screen. Each Image size is of 2.3 MB. So on loading each Image, I should see a rise of memory consumption of 3 MB approx for each Image loaded. But it turns out that it loads 10 MB for each Image.</p>
  
  <pre><code>import java.io.File;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import javafx.application.Application;
  import javafx.geometry.Orientation;
  import javafx.scene.Group;
  import javafx.scene.Scene;
  import javafx.scene.control.ScrollBar;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  import javafx.scene.layout.VBox;
  import javafx.stage.Stage;
  
  public class Test extends Application {
  
  public static void main(String... args) {
  launch(args);
  }
  
  @Override
  public void start(Stage primaryStage) throws Exception {
  ScrollBar bar = new ScrollBar();
  bar.setOrientation(Orientation.VERTICAL);
  
  
  final VBox box = new VBox();
  Group root = new Group();
  root.getChildren().addAll(box, bar);
  Scene scene = new Scene(root);
  primaryStage.setScene(scene);
  primaryStage.setTitle("Layout Sample");
  primaryStage.show();
  
  
  for (int ik = 0; ik &lt; 6; ik++) {
      System.out.println("1");
      ImageView i = new ImageView();
      InputStream is = new FileInputStream(new File("C:\\Users\\Jatin\\Documents\\BarcodeNew\\w.png"));
      Image im = new Image(is);
      i.setImage(im);
      box.getChildren().add(i);
      is.close();
  }
  
  //r.close();
  
  
  }
  }
  </code></pre>
  
  <p>In my application it is turning out that, a 1.3MB Image is taking 50 MB space. Any reasons?</p>