-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows Server 2003 Standard Edition Service Pack 1
A DESCRIPTION OF THE PROBLEM :
The source test case source code illustrates the problem best. I ran it with a specific tif file (test.tif) under c:\ using -Xmx256m and got the error added below.I increased the usable memory to -Xmx768m and followed the memory usage. I saw that during the first iteration (first call to drawImage) the memory usage for the test process reached about 390MB. I added additional iterations to see if there is a memory leak, but the memory usage stayed in about the same value through the end of the last iteration. Usage of 390MB of memory when working with images of 80-90KB seems like a bug to me (correct me if I'm wrong...).
This problem does not happen with every tif. Most of the tif files do not cause an OutOfMemoryError. below are the tif tags of the two kinds. I am willing to provide the actual files by mail if needed.
The tif tags of a tif file that causes the error:
SubFileType (1 Long): Zero
ImageWidth (1 Long): 4960
ImageLength (1 Long): 7015
BitsPerSample (1 Short): 1
Compression (1 Short): Group 3 Fax (aka CCITT FAX3)
Photometric (1 Short): MinIsWhite
FillOrder (1 Short): Msb2Lsb
ImageDescription (114 ASCII): IMAGE MAKER: Metasoft Systems, Inc. V1.0 ...
StripOffsets (1 Long): 348
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Long): 7015
StripByteCounts (1 Long): 79492
XResolution (1 Rational): 600
YResolution (1 Rational): 600
Group3Options (1 Long): 4
ResolutionUnit (1 Short): Inch
PageNumber (2 Short): 0, 1
The tif tags of a tif file that does not cause the error:
SubFileType (1 Long): Zero
ImageWidth (1 Long): 1728
ImageLength (1 Long): 2291
BitsPerSample (1 Short): 1
Compression (1 Short): Group 3 Fax (aka CCITT FAX3)
Photometric (1 Short): MinIsWhite
FillOrder (1 Short): Msb2Lsb
ImageDescription (114 ASCII): IMAGE MAKER: Metasoft Systems, Inc. V1.0 ...
StripOffsets (1 Long): 348
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Long): 2291
StripByteCounts (1 Long): 6036
XResolution (1 Rational): 204
YResolution (1 Rational): 196
Group3Options (1 Long): 5
ResolutionUnit (1 Short): Inch
PageNumber (2 Short): 0, 1
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:321)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:537)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:521)
at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:171)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2979)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2964)
at sun.java2d.pipe.DrawImage.makeBufferedImage(DrawImage.java:317)
at sun.java2d.pipe.DrawImage.renderImageXform(DrawImage.java:372)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:251)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:739)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1036)
at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:201)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3052)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3001)
at telemessage.faxconverter.OutOfMemTest.run(OutOfMemTest.java:29)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
name "test.tif" a tif file with tif tags as described below and put it under c:\ . run the added source code with -Xmx256m . I would add appropriate test files but I can't see how.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Appropriate memory usage (50-80 MB).
ACTUAL -
Memory usage of ~390MB and the error below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:321)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:537)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:521)
at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:171)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2979)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2964)
at sun.java2d.pipe.DrawImage.makeBufferedImage(DrawImage.java:317)
at sun.java2d.pipe.DrawImage.renderImageXform(DrawImage.java:372)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:251)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:739)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1036)
at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:201)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3052)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3001)
at telemessage.faxconverter.OutOfMemTest.run(OutOfMemTest.java:29)
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.RenderedOp;
import java.awt.*;
import java.awt.image.BufferedImage;
public class OutOfMemTest extends Thread{
public static void main(String[] args) {
OutOfMemTest t = new OutOfMemTest();
t.start();
}
public void run(){
BufferedImage contentImage=null;
contentImage=new BufferedImage(1648, 2120, BufferedImage.TYPE_BYTE_GRAY);
String filename;
Image loadedImage = null;
filename="c:/test.tif";
for(int i = 1; i <= 8 ; i++){
System.out.println("Iteration " + i + " started");
RenderedOp renderedOp = JAI.create("fileload", filename);
PlanarImage planarImage = PlanarImage.wrapRenderedImage(renderedOp);
renderedOp.dispose();
loadedImage = planarImage.getAsBufferedImage();
planarImage.dispose();
if (loadedImage!=null) {
Graphics g=contentImage.getGraphics();
g.drawImage(loadedImage, 75, 0, 1573, 2120, 0, 0, 4960, 7015,null);
loadedImage.flush();
}
System.out.println("Iteration " + i + " ended\n");
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
try {
sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
increase -Xmx to over 400MB
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows Server 2003 Standard Edition Service Pack 1
A DESCRIPTION OF THE PROBLEM :
The source test case source code illustrates the problem best. I ran it with a specific tif file (test.tif) under c:\ using -Xmx256m and got the error added below.I increased the usable memory to -Xmx768m and followed the memory usage. I saw that during the first iteration (first call to drawImage) the memory usage for the test process reached about 390MB. I added additional iterations to see if there is a memory leak, but the memory usage stayed in about the same value through the end of the last iteration. Usage of 390MB of memory when working with images of 80-90KB seems like a bug to me (correct me if I'm wrong...).
This problem does not happen with every tif. Most of the tif files do not cause an OutOfMemoryError. below are the tif tags of the two kinds. I am willing to provide the actual files by mail if needed.
The tif tags of a tif file that causes the error:
SubFileType (1 Long): Zero
ImageWidth (1 Long): 4960
ImageLength (1 Long): 7015
BitsPerSample (1 Short): 1
Compression (1 Short): Group 3 Fax (aka CCITT FAX3)
Photometric (1 Short): MinIsWhite
FillOrder (1 Short): Msb2Lsb
ImageDescription (114 ASCII): IMAGE MAKER: Metasoft Systems, Inc. V1.0 ...
StripOffsets (1 Long): 348
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Long): 7015
StripByteCounts (1 Long): 79492
XResolution (1 Rational): 600
YResolution (1 Rational): 600
Group3Options (1 Long): 4
ResolutionUnit (1 Short): Inch
PageNumber (2 Short): 0, 1
The tif tags of a tif file that does not cause the error:
SubFileType (1 Long): Zero
ImageWidth (1 Long): 1728
ImageLength (1 Long): 2291
BitsPerSample (1 Short): 1
Compression (1 Short): Group 3 Fax (aka CCITT FAX3)
Photometric (1 Short): MinIsWhite
FillOrder (1 Short): Msb2Lsb
ImageDescription (114 ASCII): IMAGE MAKER: Metasoft Systems, Inc. V1.0 ...
StripOffsets (1 Long): 348
SamplesPerPixel (1 Short): 1
RowsPerStrip (1 Long): 2291
StripByteCounts (1 Long): 6036
XResolution (1 Rational): 204
YResolution (1 Rational): 196
Group3Options (1 Long): 5
ResolutionUnit (1 Short): Inch
PageNumber (2 Short): 0, 1
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:321)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:537)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:521)
at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:171)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2979)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2964)
at sun.java2d.pipe.DrawImage.makeBufferedImage(DrawImage.java:317)
at sun.java2d.pipe.DrawImage.renderImageXform(DrawImage.java:372)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:251)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:739)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1036)
at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:201)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3052)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3001)
at telemessage.faxconverter.OutOfMemTest.run(OutOfMemTest.java:29)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
name "test.tif" a tif file with tif tags as described below and put it under c:\ . run the added source code with -Xmx256m . I would add appropriate test files but I can't see how.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Appropriate memory usage (50-80 MB).
ACTUAL -
Memory usage of ~390MB and the error below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:321)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:537)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:521)
at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:171)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2979)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2964)
at sun.java2d.pipe.DrawImage.makeBufferedImage(DrawImage.java:317)
at sun.java2d.pipe.DrawImage.renderImageXform(DrawImage.java:372)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:251)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:739)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1036)
at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:201)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3052)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3001)
at telemessage.faxconverter.OutOfMemTest.run(OutOfMemTest.java:29)
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.RenderedOp;
import java.awt.*;
import java.awt.image.BufferedImage;
public class OutOfMemTest extends Thread{
public static void main(String[] args) {
OutOfMemTest t = new OutOfMemTest();
t.start();
}
public void run(){
BufferedImage contentImage=null;
contentImage=new BufferedImage(1648, 2120, BufferedImage.TYPE_BYTE_GRAY);
String filename;
Image loadedImage = null;
filename="c:/test.tif";
for(int i = 1; i <= 8 ; i++){
System.out.println("Iteration " + i + " started");
RenderedOp renderedOp = JAI.create("fileload", filename);
PlanarImage planarImage = PlanarImage.wrapRenderedImage(renderedOp);
renderedOp.dispose();
loadedImage = planarImage.getAsBufferedImage();
planarImage.dispose();
if (loadedImage!=null) {
Graphics g=contentImage.getGraphics();
g.drawImage(loadedImage, 75, 0, 1573, 2120, 0, 0, 4960, 7015,null);
loadedImage.flush();
}
System.out.println("Iteration " + i + " ended\n");
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
try {
sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
increase -Xmx to over 400MB