mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trustin Lee (JIRA)" <j...@apache.org>
Subject [jira] Reopened: (DIRMINA-346) huge memory impact on receiving big packets (about 1MByte) due to CumulativeProtocolDecoder.storeRemainingInSession behaviour
Date Fri, 02 Feb 2007 14:40:07 GMT

     [ https://issues.apache.org/jira/browse/DIRMINA-346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Trustin Lee reopened DIRMINA-346:
---------------------------------


Reopening because I forgot to specify the 'Fix Version'

> 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
>         Assigned To: Trustin Lee
>
> 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.


Mime
View raw message