JDK-6751792 : OutOfMemory error from native leak in PNGEnoder class?
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0u18
  • Priority: P2
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2008-09-24
  • Updated: 2011-02-16
  • Resolved: 2009-06-24
Related Reports
Relates :  
Relates :  
Description
We are using ImageIO in one of our products and are experiencing OutOfMemory errors from what appears to be a native memory leak.  The Java Heap is fine at the point of the error.  Here is a stack trace from one of the crashes:

------------------

 
 

Root Cause:   java.lang.OutOfMemoryError

        at java.util.zip.Deflater.init(Native Method)
        at java.util.zip.Deflater.<init>(Deflater.java:117)
        at java.util.zip.Deflater.<init>(Deflater.java:126)
        at com.sun.imageio.plugins.png.IDATOutputStream.<init>(PNGImageWriter.java:139)
        at com.sun.imageio.plugins.png.PNGImageWriter.write_IDAT(PNGImageWriter.java:894)
        at com.sun.imageio.plugins.png.PNGImageWriter.write(PNGImageWriter.java:1123)
        at javax.imageio.ImageWriter.write(ImageWriter.java:598)
        at javax.imageio.ImageIO.write(ImageIO.java:1450)
        at javax.imageio.ImageIO.write(ImageIO.java:1524)

Here is the relevant code from the PNG package:

----------------
 

package com.sun.imageio.plugins.png;

import java.io.IOException;
import java.util.zip.Deflater;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.stream.ImageOutputStreamImpl;

// Referenced classes of package com.sun.imageio.plugins.png:\

//            CRC

class IDATOutputStream extends ImageOutputStreamImpl
{
    public IDATOutputStream(ImageOutputStream imageoutputstream, int i)
        throws IOException
    {
        crc = new CRC();
        def = new Deflater(9);
        buf = new byte[512];
        stream = imageoutputstream;
        chunkLength = i;
        startChunk();
    }



We believe the following bug is applicable:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4797189