-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b14
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2216217 | 7u4 | Anthony Petrov | P4 | Closed | Fixed | b06 |
I'm running
java -version
java version "1.7.0_147-icedtea"
OpenJDK Runtime Environment (IcedTea7 2.0pre) (7~b147-2.0~pre6-1ubuntu1)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)
and profiling a simple Swing application.
Just by opening a JFrame and moving the mouse over it for 10 secods I
see 600 MB of char[] being created. I can easily create several
terabytes or those if I move the mouse a little longer. Thanks to the
incredibly efficient garbage collector the application performance is
not visibly affected on my 4GB quad core machine.
The problem is an incredibly inefficient method
sun.awt.X11.XEvent.getFieldsAsString() which I pasted at the end of this
message.
The way it it handling string concatenation forces StringBuilder to grow
many times and ends up calling Arrays.copyOf a lot of times.
It is being called by the sun.awt.X11.XWrapperBase.toString() just for
the sake of logging here:
sun.awt.X11.XComponentPeer
protected boolean isEventDisabled(XEvent e)
enableLog.finest("Component is {1}, checking for disabled event {0}", e,
(isEnabled()?"enabled":"disable"));
The worse part is that even if logging is disabled and nothing at all is
ever logged, the toString is called anyway and all those char[] are
created anyway.
java -version
java version "1.7.0_147-icedtea"
OpenJDK Runtime Environment (IcedTea7 2.0pre) (7~b147-2.0~pre6-1ubuntu1)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)
and profiling a simple Swing application.
Just by opening a JFrame and moving the mouse over it for 10 secods I
see 600 MB of char[] being created. I can easily create several
terabytes or those if I move the mouse a little longer. Thanks to the
incredibly efficient garbage collector the application performance is
not visibly affected on my 4GB quad core machine.
The problem is an incredibly inefficient method
sun.awt.X11.XEvent.getFieldsAsString() which I pasted at the end of this
message.
The way it it handling string concatenation forces StringBuilder to grow
many times and ends up calling Arrays.copyOf a lot of times.
It is being called by the sun.awt.X11.XWrapperBase.toString() just for
the sake of logging here:
sun.awt.X11.XComponentPeer
protected boolean isEventDisabled(XEvent e)
enableLog.finest("Component is {1}, checking for disabled event {0}", e,
(isEnabled()?"enabled":"disable"));
The worse part is that even if logging is disabled and nothing at all is
ever logged, the toString is called anyway and all those char[] are
created anyway.
- backported by
-
JDK-2216217 sun.awt.X11.XEvent is creating 600 MB of char[] for no good reason
-
- Closed
-
- relates to
-
JDK-7105529 XAWT: Optimize getFieldsAsString() methods generated by WrapperGenerator
-
- Resolved
-