Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40495

Memory leak in BatchWriteOp

    • Fully Compatible
    • ALL
    • 65

      Memory for a batch is allocated here using 'new', and is only deallocated when _cancelBatches is called.

      In the code path added in a recent commit, there's a new early return which does not call _cancelBatches, compared to the adjacent branch below, which does.

      _cancelBatches does need to be called in both places, and adding it to the new branch would fix the memory leak.

      However, I don't see any reason we should be using raw pointers with memory allocated using 'new' here. We should probably either change this to use smart pointers or stack allocated memory so that we don't have to worry about introducing memory leaks accidentally in the future.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            matthew.saltz@mongodb.com Matthew Saltz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: