Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f72729f5
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f72729f5
编写于
5月 16, 2015
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8041654: OutOfMemoryError: RepaintManager doesn't clean up cache of volatile images
Reviewed-by: azvegint, ant
上级
f9520d17
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
132 addition
and
24 deletion
+132
-24
src/share/classes/javax/swing/RepaintManager.java
src/share/classes/javax/swing/RepaintManager.java
+19
-7
src/solaris/classes/sun/awt/X11/XToolkit.java
src/solaris/classes/sun/awt/X11/XToolkit.java
+31
-17
test/javax/swing/RepaintManager/DisplayListenerLeak/DisplayListenerLeak.java
...paintManager/DisplayListenerLeak/DisplayListenerLeak.java
+82
-0
未找到文件。
src/share/classes/javax/swing/RepaintManager.java
浏览文件 @
f72729f5
...
...
@@ -181,9 +181,16 @@ public class RepaintManager
*/
private
final
ProcessingRunnable
processingRunnable
;
private
final
static
JavaSecurityAccess
javaSecurityAccess
=
SharedSecrets
.
getJavaSecurityAccess
();
private
static
final
JavaSecurityAccess
javaSecurityAccess
=
SharedSecrets
.
getJavaSecurityAccess
();
/**
* Listener installed to detect display changes. When display changes,
* schedules a callback to notify all RepaintManagers of the display
* changes.
*/
private
static
final
DisplayChangedListener
displayChangedHandler
=
new
DisplayChangedHandler
();
static
{
SwingAccessor
.
setRepaintManagerAccessor
(
new
SwingAccessor
.
RepaintManagerAccessor
()
{
...
...
@@ -225,8 +232,8 @@ public class RepaintManager
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
if
(
ge
instanceof
SunGraphicsEnvironment
)
{
((
SunGraphicsEnvironment
)
ge
).
addDisplayChangedListener
(
new
DisplayChangedHandler
()
);
((
SunGraphicsEnvironment
)
ge
).
addDisplayChangedListener
(
displayChangedHandler
);
}
Toolkit
tk
=
Toolkit
.
getDefaultToolkit
();
if
((
tk
instanceof
SunToolkit
)
...
...
@@ -1649,6 +1656,12 @@ public class RepaintManager
*/
private
static
final
class
DisplayChangedHandler
implements
DisplayChangedListener
{
// Empty non private constructor was added because access to this
// class shouldn't be generated by the compiler using synthetic
// accessor method
DisplayChangedHandler
()
{
}
public
void
displayChanged
()
{
scheduleDisplayChanges
();
}
...
...
@@ -1656,11 +1669,10 @@ public class RepaintManager
public
void
paletteChanged
()
{
}
private
void
scheduleDisplayChanges
()
{
private
static
void
scheduleDisplayChanges
()
{
// To avoid threading problems, we notify each RepaintManager
// on the thread it was created on.
for
(
Object
c
:
AppContext
.
getAppContexts
())
{
AppContext
context
=
(
AppContext
)
c
;
for
(
AppContext
context
:
AppContext
.
getAppContexts
())
{
synchronized
(
context
)
{
if
(!
context
.
isDisposed
())
{
EventQueue
eventQueue
=
(
EventQueue
)
context
.
get
(
...
...
src/solaris/classes/sun/awt/X11/XToolkit.java
浏览文件 @
f72729f5
...
...
@@ -598,14 +598,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
}
}
if
(
keyEventLog
.
isLoggable
(
PlatformLogger
.
Level
.
FINE
)
&&
(
ev
.
get_type
()
==
XConstants
.
KeyPress
||
ev
.
get_type
()
==
XConstants
.
KeyRelease
)
)
{
keyEventLog
.
fine
(
"before XFilterEvent:"
+
ev
);
if
(
keyEventLog
.
isLoggable
(
PlatformLogger
.
Level
.
FINE
)
&&
(
ev
.
get_type
()
==
XConstants
.
KeyPress
||
ev
.
get_type
()
==
XConstants
.
KeyRelease
))
{
keyEventLog
.
fine
(
"before XFilterEvent:"
+
ev
);
}
if
(
XlibWrapper
.
XFilterEvent
(
ev
.
getPData
(),
w
))
{
continue
;
}
if
(
keyEventLog
.
isLoggable
(
PlatformLogger
.
Level
.
FINE
)
&&
(
ev
.
get_type
()
==
XConstants
.
KeyPress
||
ev
.
get_type
()
==
XConstants
.
KeyRelease
)
)
{
keyEventLog
.
fine
(
"after XFilterEvent:"
+
ev
);
// IS THIS CORRECT?
if
(
keyEventLog
.
isLoggable
(
PlatformLogger
.
Level
.
FINE
)
&&
(
ev
.
get_type
()
==
XConstants
.
KeyPress
||
ev
.
get_type
()
==
XConstants
.
KeyRelease
))
{
keyEventLog
.
fine
(
"after XFilterEvent:"
+
ev
);
// IS THIS CORRECT?
}
dispatchEvent
(
ev
);
...
...
@@ -621,21 +626,28 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
}
/**
* Listener installed to detect display changes.
*/
private
static
final
DisplayChangedListener
displayChangedHandler
=
new
DisplayChangedListener
()
{
@Override
public
void
displayChanged
()
{
// 7045370: Reset the cached values
XToolkit
.
screenWidth
=
-
1
;
XToolkit
.
screenHeight
=
-
1
;
}
@Override
public
void
paletteChanged
()
{
}
};
static
{
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
if
(
ge
instanceof
SunGraphicsEnvironment
)
{
((
SunGraphicsEnvironment
)
ge
).
addDisplayChangedListener
(
new
DisplayChangedListener
()
{
@Override
public
void
displayChanged
()
{
// 7045370: Reset the cached values
XToolkit
.
screenWidth
=
-
1
;
XToolkit
.
screenHeight
=
-
1
;
}
@Override
public
void
paletteChanged
()
{}
});
((
SunGraphicsEnvironment
)
ge
).
addDisplayChangedListener
(
displayChangedHandler
);
}
}
...
...
@@ -645,7 +657,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
try
{
XWindowAttributes
pattr
=
new
XWindowAttributes
();
try
{
XlibWrapper
.
XGetWindowAttributes
(
XToolkit
.
getDisplay
(),
XToolkit
.
getDefaultRootWindow
(),
pattr
.
pData
);
XlibWrapper
.
XGetWindowAttributes
(
XToolkit
.
getDisplay
(),
XToolkit
.
getDefaultRootWindow
(),
pattr
.
pData
);
screenWidth
=
(
int
)
pattr
.
get_width
();
screenHeight
=
(
int
)
pattr
.
get_height
();
}
finally
{
...
...
test/javax/swing/RepaintManager/DisplayListenerLeak/DisplayListenerLeak.java
0 → 100644
浏览文件 @
f72729f5
/*
* Copyright (c) 2015, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.BorderLayout
;
import
java.awt.Dimension
;
import
java.awt.EventQueue
;
import
java.awt.GraphicsEnvironment
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
import
sun.java2d.SunGraphicsEnvironment
;
/**
* @test
* @bug 8041654
* @run main/othervm -Xmx80m DisplayListenerLeak
*/
public
final
class
DisplayListenerLeak
{
private
static
JFrame
frame
;
private
volatile
static
boolean
failed
=
false
;
private
static
void
createAndShowGUI
()
{
Thread
.
currentThread
().
setUncaughtExceptionHandler
((
t
,
e
)
->
{
e
.
printStackTrace
();
failed
=
true
;
});
frame
=
new
JFrame
();
JLabel
emptyLabel
=
new
JLabel
(
""
);
emptyLabel
.
setPreferredSize
(
new
Dimension
(
600
,
400
));
frame
.
getContentPane
().
add
(
emptyLabel
,
BorderLayout
.
CENTER
);
frame
.
pack
();
frame
.
setVisible
(
true
);
}
public
static
void
main
(
final
String
[]
args
)
throws
Exception
{
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
if
(!(
ge
instanceof
SunGraphicsEnvironment
))
{
return
;
}
EventQueue
.
invokeAndWait
(()
->
createAndShowGUI
());
SunGraphicsEnvironment
sge
=
(
SunGraphicsEnvironment
)
ge
;
final
long
startTime
=
System
.
nanoTime
();
while
(!
failed
)
{
if
(
System
.
nanoTime
()
-
startTime
>
60_000_000_000L
)
{
break
;
}
System
.
gc
();
// clear all weak references
EventQueue
.
invokeAndWait
(()
->
{
frame
.
setSize
(
frame
.
getHeight
(),
frame
.
getWidth
());
frame
.
pack
();
});
EventQueue
.
invokeAndWait
(
sge:
:
displayChanged
);
}
EventQueue
.
invokeAndWait
(
frame:
:
dispose
);
if
(
failed
)
{
throw
new
RuntimeException
();
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录