Improper closing of deflater object results in native memory exhaustion

Technote (troubleshooting)


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.


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 Method)

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 {

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.  

Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK

Rate this page:

(0 users)Average rating

Add comments

Document information

More support for:

WebSphere Application Server
Out of Memory

Software version:

5.1.1, 6.0.2, 6.1

Operating system(s):

AIX, Linux, Windows

Software edition:

Base, Express, Network Deployment

Reference #:


Modified date:


Translate my page

Machine Translation

Content navigation