Are you positive you closed the stream and invoked end
on the deflater? I'm sorry if this is a simplistic suggestion you've already tried, but there were a lot of complaints about a memory leak when using Deflater
when not immediately invoking end
on it, for example:
- http://www-01.ibm.com/support/docview.wss?uid=swg21227106
- http://bugs.sun.com/view_bug.do?bug_id=6734186 (1.5)
- excessive memory use by java
- http://bugs.sun.com/view_bug.do?bug_id=4797189
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6293787
- http://kohsuke.org/2011/11/04/quiz-answer-memory-leak-in-java/
The root cause is apparently that the collector is not able to keep up with the application when memory used by native elements is involved. That also explains the behavior you are seeing when profiling: the memory is ready to be reclaimed, but just isn't reclaimed quickly enough.
Since you wrote you don't use a Deflator
directly but through Apache Thrift, try to identify which method in that library is responsible for ending the deflator, and made sure you invoked that method.