Skip to content

Instantly share code, notes, and snippets.

@geek
Last active January 6, 2016 16:20
Show Gist options
  • Save geek/25782ebdc76c1ecafcc4 to your computer and use it in GitHub Desktop.
Save geek/25782ebdc76c1ecafcc4 to your computer and use it in GitHub Desktop.
mem leak investigation
PID COMMAND %CPU TIME #PORTS MEM
35084 node 2.2 19:55.75 29 73M+

service source

'use strict';

const Seneca = require('./');

const seneca = Seneca();
seneca.add({ cmd: 'config' }, function (args, callback) {
  callback(null, { value: 2 });
});


seneca.add({ cmd: 'salestax' }, function (args, callback) {
  seneca.act({ cmd: 'config' }, function (err, result) {
    if (err) {
      return callback(err, null);
    }

    callback(null, { total: (args.net * result.value) })
  });
});

seneca.listen({
  type: 'http',
  port: 10002
});

client source

'use strict';

const Seneca = require('./');

const seneca = Seneca();

const act = function () {
  seneca.act({ cmd: 'salestax', net: 2 }, function (err, result) {
    setTimeout(act, 50);
  });
};

seneca.ready(act);
seneca.client({
  type: 'http',
  port: 10002
});

run commands

service:

$ node --max-old-space-size=100  service.js

client:

$ node client.js

node version:

$ node --version
v4.2.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment