[8u] RFR 8209113: Use WeakReference for lastFontStrike for created Fonts
Hohensee, Paul
hohensee at amazon.com
Mon Mar 23 20:55:44 UTC 2020
Sorry for empty email, fumble-fingers.
Now the whole hunk is indented one space too much. Should be:
@@ -105,7 +107,22 @@
* This pre-supposes that a FontStrike is a shareable object, which
* it should.
*/
- protected Reference lastFontStrike = new SoftReference(null);
+ protected Reference<FontStrike> lastFontStrike = new WeakReference<>(null);
+
+ /*
+ * if useWeak is true, proactively clear the cache after this
+ * many strikes are present. 0 means leave it alone.
+ */
+ private int strikeCacheMax = 0;
+ /*
+ * Whether to use weak refs for this font, even if soft refs is the default.
+ */
+ private boolean useWeak;
+
+ void setUseWeakRefs(boolean weak, int maxStrikes) {
+ this.useWeak = weak;
+ this.strikeCacheMax = weak && maxStrikes > 0 ? maxStrikes : 0;
+ }
/*
* POSSIBLE OPTIMISATION:
Paul
On 3/23/20, 1:51 PM, "Hohensee, Paul" <hohensee at amazon.com> wrote:
On 3/23/20, 11:38 AM, "Zhengyu Gu" <zgu at redhat.com> wrote:
Thanks, Paul.
Fixed indents:
http://cr.openjdk.java.net/~zgu/JDK-8209113-8u/webrev.01/
-Zhengyu
On 3/23/20 2:20 PM, Hohensee, Paul wrote:
> Lgtm, except there's an over-indentation issue in the 2nd hunk for Font2D.java.
>
> Paul
>
> On 3/20/20, 3:02 PM, "jdk8u-dev on behalf of Zhengyu Gu" <jdk8u-dev-bounces at openjdk.java.net on behalf of zgu at redhat.com> wrote:
>
> Hi,
>
> I would like to backport this change to JDK8u. This patch fixes a memory
> leak that can be reproduced in 8u.
>
> The original patch does not apply cleanly. Other than location mismatch,
> I changed
> FontStrikeDisposer.strikeCache type in original patch
> ConcurrentHashMap<FontStrikeDesc, Reference<FontStrike>> =>
> ConcurrentHashMap<FontStrikeDesc, Reference>
> to match Font2D.strikeCache
>
> Original bug: https://bugs.openjdk.java.net/browse/JDK-8209113
> Original code review thread:
> https://mail.openjdk.java.net/pipermail/2d-dev/2019-December/010470.html
>
>
> 8u Webrev:
> http://cr.openjdk.java.net/~zgu/JDK-8209113-8u/webrev.00/index.html
>
> Test:
> The testcase in bug.
>
> Thanks,
>
> -Zhengyu
>
>
>
More information about the jdk8u-dev
mailing list