|
Quick Lists
|
|
Bug ID:
|
6687968
|
|
Votes
|
1
|
|
Synopsis
|
PNGImageReader leaks native memory through an Inflater.
|
|
Category
|
java:imageio
|
|
Reported Against
|
|
|
Release Fixed
|
7(b43)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
2-High
|
|
Related Bugs
|
4797189
|
|
Submit Date
|
14-APR-2008
|
|
Description
|
FULL PRODUCT VERSION :
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Any OS which exhibits Bug #4797189.
A DESCRIPTION OF THE PROBLEM :
Line 1228 of PNGImageReader creates a new Inflater and passes it into an InflaterInputStream:
is = new InflaterInputStream(is, new Inflater());
Inspection of the InflaterInputStream code reveals that this Inflater will never be "end"ed, even by a call to "close", causing a leak of memory as described in Bug #4797189.
A reference to the Inflater should be maintained and properly "end"ed in the "PNGImageReader .dispose" method.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program to reproduce.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected normal heap usage.
ACTUAL -
Actual heap usage mimics that of Bug #4797189.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import javax.imageio.ImageReadParam;
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.ImageInputStream;
import com.sun.imageio.plugins.png.PNGImageReader;
import com.sun.imageio.plugins.png.PNGImageReaderSpi;
public class Leak
{
public static void main(String[] args) throws Exception
{
while (true)
{
ImageInputStream stream = new FileImageInputStream(new File("image.png"));
PNGImageReader imageReader = new PNGImageReader(new PNGImageReaderSpi());
imageReader.setInput(stream);
imageReader.read(0, new ImageReadParam());
imageReader.dispose();
stream.close();
}
}
}
---------- END SOURCE ----------
Posted Date : 2008-04-14 08:34:20.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
Its not strictly a leak, its less than prompt finalization
The code that creates the Inflater instance is presumably doing so precisely so
that it can release that resource in a timely manner without closing the
client-supplied input stream, but it fails to do.
When not explicitly providing an Inflater instance InflaterInputStream instances
need to be close()'d asap to release the Inflater
instance. This needs to be done in one other place in PNGImageReader.
Posted Date : 2008-07-22 23:05:51.0
|
|
Comments
|
Submitted On 04-JUL-2008
Paul_M_Taylor
I have exactly this issue, whats the workaround ?
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |