-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
1.4.2
-
x86
-
linux
Name: rmT116609 Date: 04/18/2003
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Red Hat Linux release 7.3 (Valhalla)
Kernel 2.4.18-5 on an i686
A DESCRIPTION OF THE PROBLEM :
There is still a memory leak in GZIPOutputStream although this has been reported as "fixed" before (bugs 4475540, 4652932). It seems to be very sensitive to a number of factors and is actually worse when compressing smaller buffers. The original application (from which this test case was developed) grew over 1000 MB before crashing.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program while observing its memory usage (via "top" or another tool) in another window.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Steady-state memory usage of perhaps 10 megabytes.
Memory usage grows quickly to about 270 megabytes, then continues to grow slowly beyond that.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// demonstrates GZIPOutputStream memory leak
// tested on Linux
//
// java 1.4.1_02-b06: grows quickly to 248MB, then slowly from there
// java 1.4.2-beta-b19: grows quickly to 270MB, then slowly from there
//
// if close() is called, stays at about 10MB
import java.io.*;
import java.util.zip.*;
class GZLeak {
public static void main(String[] args) throws Exception {
byte[] b1 = new byte[10];
while (true) {
ByteArrayOutputStream bo = new ByteArrayOutputStream(b1.length);
GZIPOutputStream zo = new GZIPOutputStream(bo);
DataOutputStream o = new DataOutputStream(zo);
o.write(b1, 0, b1.length);
o.flush();
zo.finish();
// zo.close(); // enable this line to avoid leak
}
}
} // class GZLeak
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Call close() after calling finish().
(Review ID: 184393)
======================================================================
- relates to
-
JDK-4026510 (refs) objects with finalizers cause inefficient garbage collection
-
- Closed
-