[
https://issues.apache.org/jira/browse/DIRMINA-772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12859325#action_12859325
]
Jörg Michelberger commented on DIRMINA-772:
-------------------------------------------
You are right no message get stuck once session is closed.
If you use a ProtocolCodecFilter in your FilterChain, your first WriteRequest
is passed through the FilterChain and in ProtocolCodecFilter the WriteRequest
is passed to getEncoderOut(session,nextFilter,writeRequest). This method
instantates a ProtocolEncoderOutputImpl storing the writeRequest. The
ProtocolEncoderOutputImpl is stored in the session as attribute ENCODER_OUT.
So the first WriteRequest with its message buffer is stored indirect in the
session. If the WriteRequest contains a message with login data, or a large
allocated buffer, it stucks until session is closed.
The reason why the WriteRequest is stored is to have the information of the
writeRequest.getDestination() and in throwing a Exception
NothingWrittenException(writeRequest) in flush of ProtocolEncoderOutputImpl.
It is a better idea only to store the information needed in
ProtocolEncoderOutputImpl and release the writeRequest object.
Regards
Jörg Michelberger
> First sent message is not garbage collected per session
> -------------------------------------------------------
>
> Key: DIRMINA-772
> URL: https://issues.apache.org/jira/browse/DIRMINA-772
> Project: MINA
> Issue Type: Bug
> Affects Versions: 2.0.0-RC1
> Environment: WinXP JDK 1.6.1_18
> Reporter: Jörg Michelberger
>
> Hi there,
> I did a heap dump of my application containing MINA 2.0.0RC1 and found a lot
> of my messages not garbage collected.
> I use ProtocolCodecFilter.
> After a investigation with VisualVM I found my already sent messages stucking
> in a DefaultWriteRequest as attribute message.
> The DefaultWriteRequest is attribute writeRequest in
> ProtocolCodecFilter$ProtocolEncoderOutputImpl.
> ProtocolCodecFilter$ProtocolEncoderOutputImpl stucks with key ENCODER_OUT in
> the sessions attribute map.
> WriteRequest in ProtocolCodecFilter$ProtocolEncoderOutputImpl is not released
> after flushing...
> The attribute ENCODER_OUT is never removed from attributes.
> Seems that only first Message stucks ProtocolEncoderOutputImpl as result of
> constructor call of ProtocolCodecFilter line 543. ProtocolEncoderOutputImpl
> is stored for later usage in ProtocolCodecFilter line 298, but only for
> providing public void write(Object encodedMessage) API.
> Hmm, ProtocolEncoderOutputImpl should store not the whole WriteRequest, only
> significant data.
> ProtocolCodecFilter.java
> private ProtocolEncoderOutput getEncoderOut(IoSession session,
> NextFilter nextFilter, WriteRequest writeRequest) {
> ProtocolEncoderOutput out = (ProtocolEncoderOutput)
> session.getAttribute(ENCODER_OUT);
>
> if (out == null) {
> // Create a new instance, and stores it into the session
> out = new ProtocolEncoderOutputImpl(session, nextFilter,
> writeRequest);
> session.setAttribute(ENCODER_OUT, out);
> }
>
> return out;
> }
> Regards
> Jörg Michelberger
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.