I work on image slide show application on JavaFX and after a while of working java crash with no free memory error. In interface code I have:
image = new ImageView();
Group root = new Group(image);
imageScene = new Scene(root, height, width);
primaryStage.setScene(imageScene);
In background thread I set image source for image view:
...
Map<String, Image> imagesMap = new HashMap<>();
...
// Slide thread
if (!imagesMap.containsKey(item.File)) {
Image image = new Image(item.File);
imagesMap.put(item.File, image);
}
Image i = imagesMap.get(item.File);
image.setImage(i);
While app run(with params: -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -Xmx256m) memory allocated to java process always is increasing...
Reduce the image size using the below code
Image img = ic.getImage();
Image newimg = img.getScaledInstance(500, 700, java.awt.Image.SCALE_SMOOTH);
I am sure you are using the original image size in this app.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.