8163261: regression on Linux: java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java

Reviewed-by: serb, alexsch
This commit is contained in:
Ambarish Rapte 2016-09-20 11:46:34 +05:30
parent 129785b09b
commit 93e6430d9f
2 changed files with 17 additions and 6 deletions

View File

@ -25,7 +25,6 @@
package sun.swing;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.*;
import java.util.*;
@ -60,7 +59,11 @@ public abstract class CachedPainter {
synchronized(CachedPainter.class) {
ImageCache cache = cacheMap.get(key);
if (cache == null) {
cache = new ImageCache(1);
if (key == PainterMultiResolutionCachedImage.class) {
cache = new ImageCache(32);
} else {
cache = new ImageCache(1);
}
cacheMap.put(key, cache);
}
return cache;
@ -271,7 +274,8 @@ public abstract class CachedPainter {
public Image getResolutionVariant(double destWidth, double destHeight) {
int w = (int) Math.ceil(destWidth);
int h = (int) Math.ceil(destHeight);
return getImage(this, c, baseWidth, baseHeight, w, h, args);
return getImage(PainterMultiResolutionCachedImage.class,
c, baseWidth, baseHeight, w, h, args);
}
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -39,7 +39,7 @@ import test.java.awt.regtesthelpers.Util;
/*
@test
@key headful
@bug 7079254
@bug 7079254 8163261
@summary Toolkit eventListener leaks memory
@library ../regtesthelpers
@build Util
@ -93,8 +93,15 @@ public class LWDispatcherMemoryLeakTest {
}
}
alloc = null;
String leakObjs = "";
if (button.get() != null) {
throw new Exception("Test failed: JButton was not collected");
leakObjs = "JButton";
}
if (p.get() != null) {
leakObjs += " JPanel";
}
if (leakObjs != "") {
throw new Exception("Test failed: " + leakObjs + " not collected");
}
}