Skip to content

Memory Leak Help #21

Description

@kirrg001

hey!

i discovered that one of my files is causing a memory leak. the memory grows over days. i'm checking everyday with htop and it grows every day more and more. i don't understand what is the reason for the memory leak. i hope somebody can help me.

var config = require(__dirname + '/config'),
  async = require('async'),
  meminfo = require('meminfo'),
  os = require('os-utils'),
  ip = require('ip'),
  timeout = null;


(function reportStats() {
  var cpuUsage = null,
    memUsage = null;

  async.waterfall([
    function(asyncDone) {
      os.cpuUsage(function(_cpuUsage) {
        cpuUsage = _cpuUsage;
        asyncDone();
      });
    },
    function(asyncDone) {
      meminfo(asyncDone);
    },
    function(_memUsage, asyncDone) {
      memUsage = _memUsage;

      // this will send a request to AWS via SQS
      config.logger.request({ cpuUsage: cpuUsage, memUsage: memUsage });
      asyncDone();
    }
  ], function(err) {
    if (err) {
      ....
    }

    clearTimeout(timeout);
    timeout = setTimeout(reportStats, 60 * 1000);
  });
}());

Thanks
kirrg

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions