INNER CODE UNIT · JavaScript

heapUsedMB

furey/mongodb-lens · mongodb-lens.js:197

    const heapUsedMB = Math.round(memoryUsage.heapUsed / 1024 / 1024)
    const heapTotalMB = Math.round(memoryUsage.heapTotal / 1024 / 1024)

    if (heapUsedMB > config.memory.warningThresholdMB) {
      log(`High memory usage: ${heapUsedMB}MB used of ${heapTotalMB}MB heap`, true)

      if (heapUsedMB > config.memory.criticalThresholdMB) {
        log('Critical memory pressure. Clearing caches…', true)
        clearMemoryCache()
        if (config.memory.enableGC && global.gc) {
          global.gc()
        } else if (config.memory.enableGC) {
          log('Garbage collection requested but not available. Run Node.js with --expose-gc flag.', true)
        }
      }
    }

    const isClientConnected = mongoClient && mongoClient.topology && mongoClient.topology.isConnected()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…