[ https://issues.apache.org/jira/browse/DIRMINA-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16809906#comment-16809906 ]
Emmanuel Lecharny commented on DIRMINA-1103: -------------------------------------------- As Jonathan said on the mailing list, resetting the {{zlib}} buffers after each call would be done a the cost of creating them back when handling a new message.Now, there are various scenarii: * each session is only used once. That's ok, when the session is 'killed', the {{zlib}} instance get garbled * each session can send many messages. You may want to reuse the {{zlib}} instance with its existing buffers, instead of creating them again and again for each compressed/decompressed messages * you have many, many sessions, with only a few of them active at a given time. In this case, not holding the{{ }}{{zlib}} buffers forever makes sense, they are only useful for the sessions being processed. Otherwise, you may have a problem with all the pending buffers which are not used but eating the memory I guess you are trying to get the third scenario implemented, right ? > Avoid sticky byte array buffers in Zlib CompressionFilter > --------------------------------------------------------- > > Key: DIRMINA-1103 > URL: https://issues.apache.org/jira/browse/DIRMINA-1103 > Project: MINA > Issue Type: Improvement > Affects Versions: 2.0.21 > Reporter: Jörg Michelberger > Priority: Major > > For each Zlib instance there is a zStream instance which is equipped with new > buffers for each in and out of inflate / deflate. This buffers are not > released after each inflate / deflate. So the last compressed and > uncompressed byte[] and its content for rx and tx is not garbage collectable > on each session. > It would be great if there was a reset(zStream) method on Zlib which sets the > in and out to static empty byte[] to release these buffers after usage quite > before returning from Zlib.deflate and Zlib.inflate but in the synchronized > block. Something like: > {{private void resetZStream (zStream) {}} > {{ zStream.next_in = EMPTY_BYTE_ARRAY;}} > {{ zStream.next_in_index = 0;}} > {{ zStream.avail_in = 0;}} > {{ zStream.next_out = EMPTY_BYTE_ARRAY;}} > {{ zStream.next_out_index = 0;}} > {{ zStream.avail_out = 0;}} > {{}}} > -- This message was sent by Atlassian JIRA (v7.6.3#76005)