JDK-4933804 : X11 colormap is created for each accelerated 24-bit offscreen image
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: solaris_8u6,1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8,solaris_9
  • CPU: generic,sparc
  • Submitted: 2003-10-07
  • Updated: 2004-01-15
  • Resolved: 2003-10-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2_04 04Fixed
Description
We're supposed to create a X11 colormap per graphics config (which means,
per visual), but we create them on each X11PixmapSurfaceData 
creation if the associated visual is a non-default 24-bit visual.
My testing configuration: SB2000 + XVR-600.

This could cause problems for certain applications which create
tons of images, because we never free the colormaps.

One can use the following command to observe the creation of 
color maps:
truss -t\!all -ulibX11::XCreateColormap,XFreeColormap java Test

The test creates accelerated offscreen images on each repaint, 
and new colormaps will be allocated for each of those images.

Here's the test case:
------- Test.java --------
import java.awt.*;

public class Test {
    static int x = 100, y = 10;
    public Test() {
	GraphicsEnvironment ge = 
	    GraphicsEnvironment.getLocalGraphicsEnvironment();
	GraphicsConfiguration gc[] = 
	    ge.getDefaultScreenDevice().getConfigurations();
	for (int i = 0; i < gc.length; i++) {
	    System.err.println("gc["+i+"]="+gc[i]);
	    if (gc[i].getColorModel().getPixelSize() == 24) {
		Frame f = new Frame(gc[i].toString(), gc[i]) {
		    public void paint(Graphics g) {
			Image im;
			System.err.println("Creating images with gc=" + 
					   getGraphicsConfiguration());
			for (int j = 0; j < 5; j++) {
			    im = createImage(100,100);
			    Graphics gim = im.getGraphics();
			    gim.setColor(Color.red);
			    gim.fillRect(0,0, im.getWidth(null), 
					 im.getHeight(null));
			    g.drawImage(im, 0,0, null);
			}
			Toolkit.getDefaultToolkit().sync();
			System.err.println("Done creating images");
		    }
		};
		f.pack();
		f.setBackground(Color.green);
		f.setLocation(x, y);
		f.setSize(300,100);
		x += f.getWidth();
		if (x + f.getWidth() > 1280) {
		    x = 100;
		    y += f.getHeight();
		}
		f.setVisible(true);
	    }
	}
    }

    public static void main(String argv[]) {
	System.setProperty("sun.java2d.pmoffscreen", "true");
	new Test();
    }
}

------- Test.java --------

###@###.### 2003-10-06

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_04 generic tiger-beta FIXED IN: 1.4.2_04 tiger-beta INTEGRATED IN: 1.4.2_04 tiger-b26 tiger-beta
14-06-2004

SUGGESTED FIX http://javaweb.sfbay/jcg/1.5.0-tiger/2D/4933804 ###@###.### 2003-10-15
15-10-2003

EVALUATION We should call awtJNI_CreateColorData in Java_sun_awt_X11SurfaceData_initSurface only for if awt_cmap is not initialized. It should be initialized in awtJNI_CreateColorData for 8-bit visuals. ###@###.### 2003-10-14
14-10-2003

WORK AROUND Disable pixmaps: -Dsun.java2d.pmoffscreen=false ###@###.### 2003-10-07
07-10-2003