diff --git a/CHANGELOG.md b/CHANGELOG.md index bb56843c..1d1961e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ FlatLaf Change Log #### Fixed bugs +- Fixed memory leak in + `MultiResolutionImageSupport.create(int,Dimension[],Function)`, + which caches images created by the producer function. Used by + `FlatSVGIcon.getImage()` and `FlatSVGUtils.createWindowIconImages()`. If you + use one of these methods, it is **strongly recommended** to upgrade to this + version, because if the returned image is larger and painted very often it may + result in an out-of-memory situation. (issue #726) - FileChooser: Fixed occasional NPE in `FlatShortcutsPanel` on Windows. (issue #718) - TextField: Fixed placeholder text painting, which did not respect horizontal diff --git a/flatlaf-core/src/main/java9/com/formdev/flatlaf/util/MultiResolutionImageSupport.java b/flatlaf-core/src/main/java9/com/formdev/flatlaf/util/MultiResolutionImageSupport.java index dd73d202..74e5c776 100644 --- a/flatlaf-core/src/main/java9/com/formdev/flatlaf/util/MultiResolutionImageSupport.java +++ b/flatlaf-core/src/main/java9/com/formdev/flatlaf/util/MultiResolutionImageSupport.java @@ -23,6 +23,7 @@ import java.awt.image.BaseMultiResolutionImage; import java.awt.image.MultiResolutionImage; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.IdentityHashMap; import java.util.List; import java.util.function.Function; @@ -134,7 +135,7 @@ public class MultiResolutionImageSupport { private final Dimension[] dimensions; private final Function producer; - private final IdentityHashMap cache = new IdentityHashMap<>(); + private final HashMap cache = new HashMap<>(); ProducerMultiResolutionImage( Dimension[] dimensions, Function producer ) { this.dimensions = dimensions;