Technote (troubleshooting)
Problem(Abstract)
If a deflater object is not explicitly closed and ended, a native memory leak occurs. This leak can result in OutOfMemoryError's and/or Java™ Virtual Machine (JVM) crashes.
Cause
Not explicitly closing and ending a deflater object (such as, DeflaterOutputStream, GZIPOutputStream or ZipOutputStream) causes a native memory leak. This native leak can result in OutOfMemoryError's in the WebSphere Application Server logs as well as JVM hangs and crashes. The following error in the WebSphere Application Server SystemOut.log or SystemErr.log files is a potential indicator of a native issue caused by this type of deflater leak:
java.lang.OutOfMemoryError: ZIP002:OutOfMemoryError, MEM_ERROR in deflate_init2
at java.util.zip.Deflater.init(Native Method)
at java.util.zip.Deflater.<init>(Deflater.java:135)
at java.util.zip.ZipOutputStream.<init>(ZipOutputStream.java:84)
...
Resolving the problem
To avoid the leak, the application programmer should insure that all deflater objects are explicitly closed and ended.
The following is a code for properly ending a deflater:
try {
Deflater zip = new Deflater(level);
DeflaterOutputStream defStream = new DeflaterOutputStream(out);
}
finally {
defStream.close();
zip.end();
}
If the application is not explicitly creating a Deflater object, Java creates a default Deflater. In this case, the application need only close the DeflaterOutputStream and this will end the default Deflater object. For example:
try {
/// create default Deflater
DeflaterOutputStream defStream = new DeflaterOutputStream(out);
}
finally {
/// end the Deflater object.
defStream.close();
}
| Segment | Product | Component | Platform | Version | Edition |
|---|---|---|---|---|---|
| Application Servers | Runtimes for Java Technology | Java SDK |
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.