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

Mongo Client Memory Leak

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.3
    • Component/s: Native

      I have notices that the amount of memory used by a nodejs process increases over time when I connect to a DB using a basic connection.

      The code I am executing is as follows:

      const MongoClient = require('mongodb').MongoClient;
       
      const url = "mongodb://xxx:yyy@zzz:27017/testdb?authSource=admin";}}{{
       
      new MongoClient(url, { useNewUrlParser: true, keepAlive: true, useUnifiedTopology: true }).connect();
       
      I have kept an eye on the activity monitor over time, there are two processes spawned and the initial memory usage was 56MB and 36.9MB.
       
      After two days the memory usage was 640MB and 39.1MB.
       
      I have executing this on both MacOS and Windows and am seeing the same issue. 
      I am using the MongoDB driver version 3.6.3 and have tried on NodeJS 14.15.1 and 15.6.0 with the same result
       
      We are using this in a production environment, and first noticed it because the servers were running out of memory after being up for some time.
       
      I have taken some heap snapshots if that helps:
       
      Snapshot 15th Jan
       
      Snapshot 17th Jan
       
       

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            byrondavies1@gmail.com Byron Davies
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: