Details
-
Bug
-
Resolution: Fixed
-
P3
-
7u21
-
windows_7
Description
FULL PRODUCT VERSION :
java version " 1.7.0_21 "
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Memory cumulates in process explorer, while the heap stays constant. This results in a " java.lang.OutOfMemoryError: unable to create new native thread " .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code provided to test the memory leak. If you comment the lines 9-10 out and uncomment line 12 everything goes right.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The memory should not leak.
ACTUAL -
It is leaking.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.OutOfMemoryError: unable to create new native thread
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
final JFrame frm = new JFrame();
frm.getContentPane().setLayout(new BorderLayout());
frm.getContentPane().add(new JLabel() {
@Override public void paint(Graphics g)
{
super.paint(g);
Graphics2D gd = (Graphics2D) g;
// Memory leaking:
AttributedString as = new AttributedString( " this is a memory leak " , gd.getFont().getAttributes());
gd.drawString(as.getIterator(), 100, 100);
// No memory leak:
// gd.drawString( " no memory leak here " , 100, 100);
}
}, BorderLayout.CENTER);
frm.setSize(500,350);
frm.setLocationRelativeTo(null);
frm.setVisible(true);
new Thread() {
@Override public void run() {
while(true)
{
try
{
frm.getContentPane().repaint();
Thread.sleep(1);
} catch (InterruptedException ex)
{
Logger.getLogger(SIMAVIS_S_Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}.start();
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Like described above, if you use gd.drawString( " mystring " , ...) instead of AttributedString as the first argument the memory wouldn't leak.
java version " 1.7.0_21 "
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Memory cumulates in process explorer, while the heap stays constant. This results in a " java.lang.OutOfMemoryError: unable to create new native thread " .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code provided to test the memory leak. If you comment the lines 9-10 out and uncomment line 12 everything goes right.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The memory should not leak.
ACTUAL -
It is leaking.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.OutOfMemoryError: unable to create new native thread
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
final JFrame frm = new JFrame();
frm.getContentPane().setLayout(new BorderLayout());
frm.getContentPane().add(new JLabel() {
@Override public void paint(Graphics g)
{
super.paint(g);
Graphics2D gd = (Graphics2D) g;
// Memory leaking:
AttributedString as = new AttributedString( " this is a memory leak " , gd.getFont().getAttributes());
gd.drawString(as.getIterator(), 100, 100);
// No memory leak:
// gd.drawString( " no memory leak here " , 100, 100);
}
}, BorderLayout.CENTER);
frm.setSize(500,350);
frm.setLocationRelativeTo(null);
frm.setVisible(true);
new Thread() {
@Override public void run() {
while(true)
{
try
{
frm.getContentPane().repaint();
Thread.sleep(1);
} catch (InterruptedException ex)
{
Logger.getLogger(SIMAVIS_S_Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}.start();
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Like described above, if you use gd.drawString( " mystring " , ...) instead of AttributedString as the first argument the memory wouldn't leak.
Attachments
Issue Links
- duplicates
-
JDK-8015334 Memory leak when kerning is used on Windows
-
- Resolved
-