* Performance: improved memory usage for images (now xmage will not eat all available memory on 2GB+ settings, see #6375);

This commit is contained in:
Oleg Agafonov 2020-09-09 16:47:45 +04:00
parent 233e12873e
commit cb2ae0295f
2 changed files with 18 additions and 7 deletions

View file

@ -19,6 +19,7 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
public class CardPanelRenderImpl extends CardPanel {
@ -219,7 +220,12 @@ public class CardPanelRenderImpl extends CardPanel {
}
// Map of generated images
private final static Cache<ImageKey, BufferedImage> IMAGE_CACHE = CacheBuilder.newBuilder().softValues().build();
private final static Cache<ImageKey, BufferedImage> IMAGE_CACHE = CacheBuilder
.newBuilder()
.maximumSize(3000)
.expireAfterAccess(60, TimeUnit.MINUTES)
.softValues()
.build();
// The art image for the card, loaded in from the disk
private BufferedImage artImage;