Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2460

Memory leaks when using NettyStream and CommandListener

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.0
    • Affects Version/s: 3.4.2
    • Component/s: Async
    • None

      I found some strange behaviour when NettyStream is used in async driver with a CommandListener configured. See next code example: https://gist.github.com/jamel/957aab95a8385ef43768f378fb405d25

      There I enabled high level of Netty resource leak detector to see any problems with resource leakage. When line

      .addCommandListener(new NopCommandListener())

      is commented all works just fine (see normal_run.log). But when that line is uncommented resource leak detector found some leaks (see buggy_run.log).

      After playing with this bug a little bit I found that root cause of these leaks is ByteBufBsonDocument class. When instance of this class is created it takes ownership of given buffer (because bsonOutput.getByteBuffers() increments reference counter in each returning sub buffer). Unfortunately ByteBufBsonDocument class never releases its buffer and currently there is no way to do that.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            jamel Sergey Polovko
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: