[ 
https://issues.apache.org/jira/browse/DIRMINA-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16810158#comment-16810158
 ] 

Jörg Michelberger commented on DIRMINA-1103:
--------------------------------------------

Yes, scenario 3 is my usecase and it looks like that can be realized with
low risk and overhead. The byte arrays are garbled the same as now, but one
step earlier. And idle sessions do not use as much mem as now. And there is
no guessing of buffer size for reuse of the buffers like in scenario 2
which could be tricky especially when main traffic is some bytes long and
some rare packets carry multiple megabytes where it is best to remove that
buffers as fast as possible, because with compressed and decompressed
buffers we have 3 times the size allocated and current implementation keeps
that until next message.

Regards
Joerg

Emmanuel Lecharny (JIRA) <[email protected]> schrieb am Do., 4. Apr. 2019,



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

Reply via email to