[
https://issues.apache.org/jira/browse/DIRMINA-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469767
]
Trustin Lee commented on DIRMINA-346:
-------------------------------------
This issue already has been addressed in DIRMINA-328, though the patch looks
different from yours. Please let me know if your problem has gone after using
the snapshot here:
http://tinyurl.com/2a2pre
Also, your patch will resurrect DIRMINA-201.
> huge memory impact on receiving big packets (about 1MByte) due to
> CumulativeProtocolDecoder.storeRemainingInSession behaviour
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: DIRMINA-346
> URL: https://issues.apache.org/jira/browse/DIRMINA-346
> Project: MINA
> Issue Type: Improvement
> Components: Core
> Affects Versions: 1.0.1
> Environment: Windows XP Sp2
> Java 1.5.0_10
> Client / Server VM
> Reporter: andrea sillari
>
> When receiving big TCP packets (about 1Mbyte or more) the current behavior of
> CumulativeProtocolDecoder.storeRemainingInSession implies that the session
> buffer is duplicated (and data copied) even if there is room for receiving
> another chunk of data from the socket (i.e. buf.limit() < buf.capacity()). In
> this situation there are spikes of memory consumption due to the fact that
> 1Mbyte / 8k (== session.getReadBufferSize()) = 128 buffers of increasing
> size are required for reading the entire packet.
> The attached patch prevents this, by explicitly checking if there is at least
> session.getReadBufferSize() space in the buffer, before requesting the
> allocation of a new buffer.
> The method session.getReadBufferSize() has been added to the IOSession
> Interface.
> private void storeRemainingInSession(ByteBuffer buf, IoSession session)
> {
> if (buf.limit() + session.getReadBufferSize() < buf.capacity()) //
> reuse the buffer
> {
> buf.position(buf.limit());
> buf.limit(buf.capacity());
>
> ByteBuffer sessBuff = (ByteBuffer) session.getAttribute(BUFFER);
> if (sessBuff != buf) // this should happens only the first time
> when sessBuff is null
> {
> session.setAttribute( BUFFER, buf );
> buf.acquire();
> }
> }
> else // old behavior
> {
> ByteBuffer remainingBuf = ByteBuffer.allocate( buf.remaining()
> );
> remainingBuf.setAutoExpand( true );
> remainingBuf.put( buf );
> session.setAttribute( BUFFER, remainingBuf );
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.