JDK-6223076 : Unnecessary object retention in java.util.zip.Deflater
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 1.3.1,1.4.2,5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-01-28
  • Updated: 2010-04-03
  • Resolved: 2005-04-04
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 Other JDK 6
1.3.1_16 b01Fixed 1.4.2_09Fixed 6Fixed
Related Reports
Relates :  
Description
It's not uncommon for applications that compress large quantities of data to
pass a very large byte array to the Deflater.setInput method, either directly
or via the DeflaterOutputStream.write method.  The Deflater code saves a
reference to the given byte array in a private field, and this private field is
never cleared.  Since the Deflater class has a finalization method it can take
quite a while for a Deflater instance to be garbage collected, and in the
meantime the potentially-large byte array will be kept alive for no reason.
This has been observed to cause OutOfMemoryErrors under heavy load.

This bug is present in 1.3.1, 1.4.x, 5.0, and Mustang.

###@###.### 2005-1-28 20:22:46 GMT

Comments
EVALUATION Yes. The Deflater class has a byte array that's not cleared specifically up on closure of the output stream. But, it depends on GC. De-refencing the byte array (buf) really helps from thowing OOM error in scarce memory situations, under severe load. The problem is also applicable to Inflater. Will be fixing at both places (Inflater and Deflater) for all the applicable releases. ###@###.### 2005-1-28 23:13:58 GMT ###@###.### 2005-1-28 23:55:42 GMT
28-01-2005

SUGGESTED FIX --- /tmp/scdiff.73CRBQ/qamnWS 2003-06-27 16:41:00.000000000 -0700 +++ src/share/classes/java/util/zip/Deflater.java 2005-01-23 19:02:15.000000000 -0800 @@ -329,15 +329,18 @@ if (strm != 0) { end(strm); strm = 0; + buf = null; } } ###@###.### 2005-1-28 20:22:46 GMT
28-01-2005