Message6575

Author pekka.klarck
Recipients pekka.klarck
Date 2011-07-22.07:16:29
SpamBayes Score 0.00047829995
Marked as misclassified No
Message-id <1311318990.54.0.098589343366.issue1775@psf.upfronthosting.co.za>
In-reply-to
Content
We noticed in our project that Jython leaks memory when calling zlib.compress. With something like 10000 calls compression started to be very slow and sometimes the end result was OutOfMemoryError.

I looked at the source code of Jython's zlib module and investigated java.util.zip.Deflater [1] it uses internally. I noticed that Deflator.end() as never called and after adding that to the end of  _get_deflate_data helper things improved considerably.

[1] http://download.oracle.com/javase/1.5.0/docs/api/java/util/zip/Deflater.html

In our project we ended up implementing a custom version of compress based on the Jython's zlib.compress implementation. This version, for example, only instantiates Deflater once and calls its reset method when one string has been compressed. In the end our version is ~25% faster than zlib.compress with the fix I explained above. 

I can create a patch to fix this issue and study could the enhancements we did to our compress be added too.
History
Date User Action Args
2011-07-22 07:16:30pekka.klarcksetrecipients: + pekka.klarck
2011-07-22 07:16:30pekka.klarcksetmessageid: <1311318990.54.0.098589343366.issue1775@psf.upfronthosting.co.za>
2011-07-22 07:16:30pekka.klarcklinkissue1775 messages
2011-07-22 07:16:29pekka.klarckcreate