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

Memory leak in BatchWriteOp

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.11
    • Component/s: Sharding
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Linked BF Score:
      78

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: