Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6394

bulkWrite memory leak

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 5
    • Not Needed
    • None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      I've been trying to diagnose a memory leak within my application and I've found that a leak is occurring with the `bulkWrite` operation.

      Here is a simplified version of my code which is executed in a loop (every 2 mins with new updates):
      ```
       const updates = // an array of updates
       await coll.bulkWrite(updates, { session, ordered: false });
       // updates is no longer referenced and should be freed via gc
      ```
      I'm certain that the bulkWrite is causing the memory leak. If instead I pass an empty array as a no-op, then the memory leak disappears:
      ```
       const updates = // an array of updates
       await coll.bulkWrite([], { session, ordered: false });
       // updates is no longer referenced and should be freed via gc
      ```
      Here is a graph showing the memory usage of this pod. The left line shows the first block of code that does all the updates and the second line on the right shows the empty array no-op. The code with the empty array no longer has a memory leak.

      I've also tried with `ordered: true` which still has the problem. Completely commenting out the mongo update call makes the leak disappear too.

      This issue is consistently repeatable for me. There is never not a leak with this code.

      I am running the node driver with version 6.6.0. Previous to 6.6.0 we were on a much older version (pre 6). I don't recall if we had this issue on the older version. However, we did upgrade to this newer version sometime this year. We are using atlas for the db.

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            vrecupito@booment.com Vince Recupito
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None