mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michelberger, Joerg" <JOERG.MICHELBER...@NDSatcom.com>
Subject First sent message is not garbage collected per session.
Date Mon, 15 Feb 2010 10:19:15 GMT
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.
If there are Login data inside this message, all data is stored for session lifetime in memory.

    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;

	Jörg Michelberger
View raw message