Note that there are some explanatory texts on larger screens.

plurals
  1. POHigh memory consumption by an Image
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload