-
Bug
-
Resolution: Fixed
-
P2
-
1.4.2, 5.0
-
b94
-
x86
-
windows_2003, windows_xp
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
nVidia Geforce4 Ti 4200 graphics card. nVidia drivers version 6.14.10.6177
A DESCRIPTION OF THE PROBLEM :
I have noticed that very basic drawing in a Swing application will eventually lead to a memory leak in the AWT Event thread that prevents re-painting. All that is needed to demonstrate this is a Swing app that repaints the UI periodically. I used a JFrame with a single JLabel and called repaint() ten times a second.
The tricky bit about the bug, is that it is triggered by a completely different process, in my case a fancy screen blanker that I believe uses OpenGL. If I run the described Swing app and activate the GoldFish Aquarium screen saver from www.lifeglobe.com the swing application will lose a chunk of memory. Simply repeatedly activating and deactivating the screen saver is enough to crash the Java application after only a few iterations.
The bug can be seen in Java 1.4.2_05 and Java 5.
I have only been able to reproduce this bug with that specific screen saver, only when the screen saver is set to 16 bpp and my desktop is set to 32 bpp. Presumably the 3D screen savers included with windows (e.g. 3D Pipes) don't change the bit depth, or use Direct3D instead of openGL or vice versa, They don't appear to trigger the problem.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Install the Goldfish Aquarium screen saver from www.lifeglobe.com
Set your desktop resolution to 1920x1440 32bpp
Make sure the screen saver is configured for 16bpp
Compile and run the attached Java program from a console with no options (java GraphicLeak).
Repeatedly activate and de-activate the screen saver while watching memory usage of the java process with the Windows task manager.
Eventually you will see OutOfMemoryExceptions reported in the console window where you started the Java application.
For me it happens after activating the screen saver for the seventh time.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The java application should not lose memory when another process makes use of the graphics card.
ACTUAL -
Each invocation of the screen saver causes a memory loss in the java application. The memory loss may be proportional to the size of the java application's UI.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//
import java.awt.Container;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class GraphicLeak
{
public static void main(String[] args)
{
JFrame frm = new JFrame("Memory leak");
Container cp = frm.getContentPane();
cp.add( new JLabel(
"<html>Launch Windows Task Manager<br>Maximize the size fo this window.<br>"+
"Watch the memory consumption of this process.<br>"+
"See that it is in a steady state.<br>"+
"Activate the \"Goldfish Aquarium\" screensaver<br>"+
"(free trial www.lifeglobe.com 16bpp, default res. of 1920 x1440, limit framerate)<br>"+
"Wait a few seconds minutes, stop the screen saver and look at the memory usage of this process.<br>"+
"Repeat activating the screen saver and deactivating it, several times.<br>"+
"Memory usage of this process appears to jump every time the screen saver starts and stops.<br>"+
"If left long enough Out-of-memory errors will occur with every reapint.<br>"+
"</html>"), BorderLayout.CENTER );
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.pack();
frm.setVisible(true);
while(true)
{
frm.repaint();
try { Thread.sleep(100); } catch (InterruptedException e ) {}
}
}
}
---------- END SOURCE ----------
###@###.### 2004-12-16 19:36:05 GMT
This bug is a manifestation of an even simpler situation where _any_ display mode that occurs outside of the Java application (including any screen saver activating, or hibernating the system, or another app changing the display mode, or the user changing the display mode via the control panel) will cause the java application to leak memory. If you want to reproduce the problem, run the app above (or any Swing application, actually) and change the color depth of the screen using the Display Control Panel. Bring up the Taskmanager and track the memory usage of the Java app; you will see the memory size grow with every display change. If you want to see dramatic leaks, increase the size of the Java window to be the same as your desktop size (maximize the window).
###@###.### 2005-1-06 22:33:40 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
nVidia Geforce4 Ti 4200 graphics card. nVidia drivers version 6.14.10.6177
A DESCRIPTION OF THE PROBLEM :
I have noticed that very basic drawing in a Swing application will eventually lead to a memory leak in the AWT Event thread that prevents re-painting. All that is needed to demonstrate this is a Swing app that repaints the UI periodically. I used a JFrame with a single JLabel and called repaint() ten times a second.
The tricky bit about the bug, is that it is triggered by a completely different process, in my case a fancy screen blanker that I believe uses OpenGL. If I run the described Swing app and activate the GoldFish Aquarium screen saver from www.lifeglobe.com the swing application will lose a chunk of memory. Simply repeatedly activating and deactivating the screen saver is enough to crash the Java application after only a few iterations.
The bug can be seen in Java 1.4.2_05 and Java 5.
I have only been able to reproduce this bug with that specific screen saver, only when the screen saver is set to 16 bpp and my desktop is set to 32 bpp. Presumably the 3D screen savers included with windows (e.g. 3D Pipes) don't change the bit depth, or use Direct3D instead of openGL or vice versa, They don't appear to trigger the problem.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Install the Goldfish Aquarium screen saver from www.lifeglobe.com
Set your desktop resolution to 1920x1440 32bpp
Make sure the screen saver is configured for 16bpp
Compile and run the attached Java program from a console with no options (java GraphicLeak).
Repeatedly activate and de-activate the screen saver while watching memory usage of the java process with the Windows task manager.
Eventually you will see OutOfMemoryExceptions reported in the console window where you started the Java application.
For me it happens after activating the screen saver for the seventh time.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The java application should not lose memory when another process makes use of the graphics card.
ACTUAL -
Each invocation of the screen saver causes a memory loss in the java application. The memory loss may be proportional to the size of the java application's UI.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//
import java.awt.Container;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class GraphicLeak
{
public static void main(String[] args)
{
JFrame frm = new JFrame("Memory leak");
Container cp = frm.getContentPane();
cp.add( new JLabel(
"<html>Launch Windows Task Manager<br>Maximize the size fo this window.<br>"+
"Watch the memory consumption of this process.<br>"+
"See that it is in a steady state.<br>"+
"Activate the \"Goldfish Aquarium\" screensaver<br>"+
"(free trial www.lifeglobe.com 16bpp, default res. of 1920 x1440, limit framerate)<br>"+
"Wait a few seconds minutes, stop the screen saver and look at the memory usage of this process.<br>"+
"Repeat activating the screen saver and deactivating it, several times.<br>"+
"Memory usage of this process appears to jump every time the screen saver starts and stops.<br>"+
"If left long enough Out-of-memory errors will occur with every reapint.<br>"+
"</html>"), BorderLayout.CENTER );
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.pack();
frm.setVisible(true);
while(true)
{
frm.repaint();
try { Thread.sleep(100); } catch (InterruptedException e ) {}
}
}
}
---------- END SOURCE ----------
###@###.### 2004-12-16 19:36:05 GMT
This bug is a manifestation of an even simpler situation where _any_ display mode that occurs outside of the Java application (including any screen saver activating, or hibernating the system, or another app changing the display mode, or the user changing the display mode via the control panel) will cause the java application to leak memory. If you want to reproduce the problem, run the app above (or any Swing application, actually) and change the color depth of the screen using the Display Control Panel. Bring up the Taskmanager and track the memory usage of the Java app; you will see the memory size grow with every display change. If you want to see dramatic leaks, increase the size of the Java window to be the same as your desktop size (maximize the window).
###@###.### 2005-1-06 22:33:40 GMT
- relates to
-
JDK-4899321 issue Swing back buffer issue has performance impact
- Closed
-
JDK-6928788 Display change event causes OutOfMemoryError at java.awt.image.DataBufferInt.
- Closed
-
JDK-6990010 Simple swing app leaks memory when a display mode change occurs
- Closed
-
JDK-7160027 javax/swing/RepaintManager/6209673/bug6209673.java unstable on windows vista x86 (RuntimeException)
- Closed