Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory increase non-stop with basic Sails application

To be short, I've setup a no frontend sails project with a basic controller and hit it with loadtest, the memory keeps increasing and no sign of stablizing. I've read previous posts and have disabled grunt, session, socket, pubsub and etc.

Setup:

Sails version: v0.12.3

Node version: v4.4.7

NPM version: v2.15.8

Reproduce:

create new sails project

sails new Project --no-frontend

edit .sailsrc:

{
  "generators": {
    "modules": {}
  },

  "hooks": {
    "session": false,
    "sockets": false,
    "pubsub": false,
    "grunt": false,
    "i18n": false
  }
}

added controllers/TestController.js:

module.exports = {
  hi: function (req, res) {
    return res.send("Hi there!");
  }
};

run load test:

var loadtest = require('loadtest');

var host = 'http://localhost:1337';

var options = {
    url: host + '/test/hi',
    requestsPerSecond: 50
};

loadtest.loadTest(options, function(error, result)
{
    if (error)
    {
        return console.error('Got an error: %s', error);
    }
    console.log('Tests run successfully: '+result);
});

Thank you for your help.

Mars

like image 856
Mars Zhu Avatar asked Jul 10 '16 16:07

Mars Zhu


2 Answers

I know this is likely to get a down vote for not being a specific answer or throwing out links but this topic has been covered by Mike a number of times via github issues. As there are so many variables to take into consideration he has prepared a trouble shooting guide, which whilst I could copy and paste here I do not think that is good use of anyones time. So here is the link : https://github.com/balderdashy/sails/issues/2779#issuecomment-209735285

Mike specifically mentions raising an issue on the project if you feel there is a genuine leak that is not covered off in the troubleshooting guide. I think you will only get typical recommendations on stack so for me I think you are better placed going direct to github if your issue is not fixed.

like image 181
munkee Avatar answered Nov 15 '22 05:11

munkee


  1. Take a few heap dumps before, during, and after your load test.
  2. Examine in Chrome dev tools by loading the heap dump
  3. Report the leak!

https://github.com/bnoordhuis/node-heapdump

Also, you could try forcing GC every 60 seconds or something manually by setting a timeout, to see if memory goes down after GC (which means there is not a leak).

node --expose-gc script.js

And then from within the Javascript just do:

setTimeout(function(){
     global.gc();
},60000);
like image 39
rideon88 Avatar answered Nov 15 '22 05:11

rideon88