Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-1061

When AbstractPollingIoProcessor read nothing, free the temporary buffer should be better

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.16
    • Fix Version/s: 2.0.17
    • Component/s: Core
    • Labels:
      None

      Description

      org.apache.mina.core.polling.AbstractPollingIoProcessor.java
      private void read(S session) {
              IoSessionConfig config = session.getConfig();
              int bufferSize = config.getReadBufferSize();
              IoBuffer buf = IoBuffer.allocate(bufferSize);
      //...
      //...
                  if (readBytes > 0) {
                      IoFilterChain filterChain = session.getFilterChain();
                      filterChain.fireMessageReceived(buf);
                      buf = null;
      
                      if (hasFragmentation) {
                          if (readBytes << 1 < config.getReadBufferSize()) {
                              session.decreaseReadBufferSize();
                          } else if (readBytes == config.getReadBufferSize()) {
                              session.increaseReadBufferSize();
                          }
                      }
                  }
      

      it seems that this method will be called when session closing.
      it'll better to call buf.free() if readBytes==0, to help allocator recycle this buffer, thx!

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              g_mark Mark
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: