-
Bug
-
Resolution: Duplicate
-
P5
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
I have a program that updates the mouse cursor very often. With Java 1.5 after a while the whole system freezes. Task Manager shows that the number of GDI objects increases dramatically until the limit of 9999. Then the system nearly freezes until command prompt tells a OutOfMemory error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
start the attached test program with
java cursor_update
(using for example java -Xmx256M cursor_update has the same problem, but it takes longer until it happens)
A frame with 800x600 pixels size will be created. Move the mouse in that area. The mouse cursor will be updated every 100 millisecons.
Wait a little bit and watch task manager showing the number of used GDI objects of the Java process
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Thought the Garbage collector would clear the native resources (GDI objects)
ACTUAL -
GDI objects increase, System nearly freezes
ERROR MESSAGES/STACK TRACES THAT OCCUR :
C:\arbeit\testprog\cursorbug>java cursor_update
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
public class cursor_update implements WindowListener
{
Frame ds_frame;
Cursor ds_cursor;
MemoryImageSource ds_mis;
Image ds_img;
Point ds_hotspot=new Point(0,0);
int[] imr_rawdata=new int[1024];
int im_color=0;
boolean bo_changecursor=true;
public static void main (String[] args)
{
cursor_update ds_cu = new cursor_update();
ds_cu.go();
}
void go()
{
ds_frame = new Frame("Cursor Problem");
ds_frame.addWindowListener(this);
ds_frame.pack();
ds_frame.setSize(800,600);
ds_frame.show();
while (bo_changecursor)
{
Arrays.fill(imr_rawdata,(0xFF000000 | im_color << 16) | im_color);
ds_mis=new MemoryImageSource(32, 32, imr_rawdata, 0,32);
ds_img=ds_frame.createImage(ds_mis);
ds_cursor=ds_frame.getToolkit().createCustomCursor(ds_img,ds_hotspot,"CURSOR");
ds_frame.setCursor(ds_cursor);
im_color++;
if (im_color>255)
{
im_color=0;
try
{
Thread.sleep(100);
}
catch(InterruptedException ie)
{}
}
}
}
/**************************************************************/
/* Implementation of WindowListener */
/**************************************************************/
public void windowActivated( WindowEvent wev )
{
}
public void windowClosed( WindowEvent wev )
{
}
public void windowClosing( WindowEvent wev )
{
System.out.println("windowClosing");
bo_changecursor=false;
ds_frame.dispose();
}
public void windowDeactivated( WindowEvent wev )
{
}
public void windowDeiconified( WindowEvent wev )
{
}
public void windowIconified( WindowEvent wev )
{
}
public void windowOpened( WindowEvent wev )
{
}
}
---------- END SOURCE ----------
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
I have a program that updates the mouse cursor very often. With Java 1.5 after a while the whole system freezes. Task Manager shows that the number of GDI objects increases dramatically until the limit of 9999. Then the system nearly freezes until command prompt tells a OutOfMemory error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
start the attached test program with
java cursor_update
(using for example java -Xmx256M cursor_update has the same problem, but it takes longer until it happens)
A frame with 800x600 pixels size will be created. Move the mouse in that area. The mouse cursor will be updated every 100 millisecons.
Wait a little bit and watch task manager showing the number of used GDI objects of the Java process
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Thought the Garbage collector would clear the native resources (GDI objects)
ACTUAL -
GDI objects increase, System nearly freezes
ERROR MESSAGES/STACK TRACES THAT OCCUR :
C:\arbeit\testprog\cursorbug>java cursor_update
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
public class cursor_update implements WindowListener
{
Frame ds_frame;
Cursor ds_cursor;
MemoryImageSource ds_mis;
Image ds_img;
Point ds_hotspot=new Point(0,0);
int[] imr_rawdata=new int[1024];
int im_color=0;
boolean bo_changecursor=true;
public static void main (String[] args)
{
cursor_update ds_cu = new cursor_update();
ds_cu.go();
}
void go()
{
ds_frame = new Frame("Cursor Problem");
ds_frame.addWindowListener(this);
ds_frame.pack();
ds_frame.setSize(800,600);
ds_frame.show();
while (bo_changecursor)
{
Arrays.fill(imr_rawdata,(0xFF000000 | im_color << 16) | im_color);
ds_mis=new MemoryImageSource(32, 32, imr_rawdata, 0,32);
ds_img=ds_frame.createImage(ds_mis);
ds_cursor=ds_frame.getToolkit().createCustomCursor(ds_img,ds_hotspot,"CURSOR");
ds_frame.setCursor(ds_cursor);
im_color++;
if (im_color>255)
{
im_color=0;
try
{
Thread.sleep(100);
}
catch(InterruptedException ie)
{}
}
}
}
/**************************************************************/
/* Implementation of WindowListener */
/**************************************************************/
public void windowActivated( WindowEvent wev )
{
}
public void windowClosed( WindowEvent wev )
{
}
public void windowClosing( WindowEvent wev )
{
System.out.println("windowClosing");
bo_changecursor=false;
ds_frame.dispose();
}
public void windowDeactivated( WindowEvent wev )
{
}
public void windowDeiconified( WindowEvent wev )
{
}
public void windowIconified( WindowEvent wev )
{
}
public void windowOpened( WindowEvent wev )
{
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6415734 Out of Memory when updating custom cursor frequently
-
- Closed
-