Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak on cluster mode for sails js #1453

Closed
shumailarshad opened this issue Jul 22, 2015 · 14 comments
Closed

Memory leak on cluster mode for sails js #1453

shumailarshad opened this issue Jul 22, 2015 · 14 comments

Comments

@shumailarshad
Copy link

I have created a new sails js app and did not change any code in it.

Than I used pm2 to launch two instance of that app. Memory keep increasing without hitting app even once.

I have done the same with basic express.js app with following code but it does not increase memory

"
var express = require('express');
var app = express();

app.get('/', function (req, res) {
res.send('Hello World!');
});

var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;

console.log('Example app listening at http://%s:%s', host, port);
});
"
After around 2 - 3 hrs.. It comes up to:
screenshot from 2015-07-21 17 59 17

After leaving it overnight.. It comes up to:
screenshot from 2015-07-22 09 11 44

@soyuka
Copy link
Collaborator

soyuka commented Jul 22, 2015

How is this related to pm2?

@shumailarshad
Copy link
Author

And when I use fork mode, it did not increase alot and stayed more steady.

screenshot from 2015-07-22 09 52 36

@shumailarshad
Copy link
Author

I am not sure but it only happens on cluster mode not fork mode (standalone sails app)

@soyuka
Copy link
Collaborator

soyuka commented Jul 22, 2015

So? No memory leak with express in cluster mode? Conclusion: it should be related to sails.

@Unitech Unitech added the leak? label Jul 22, 2015
@jshkurti
Copy link
Contributor

Which version of Node.js and Sails exactly ?
I would like to reproduce this bug.
Also a sample code would be nice.

Thanks for reporting this @shumailarshad

@jshkurti jshkurti self-assigned this Jul 27, 2015
@jshkurti
Copy link
Contributor

Bug confirmed. Inspecting this

@shumailarshad
Copy link
Author

That is not problem. Please do let me know if you need any help in fixing this bug or any other.

Also, if you need to any more testing on my side, please do let me know.

@shumailarshad
Copy link
Author

So I didn't write single line of code. Just did
sails new sailsApp
pm2 start app.js -i 2 --name "sailsApp"

@jshkurti
Copy link
Contributor

Yep thanks. I managed to reproduce it. sails new project; cd project; pm2 start app.js -i 2.
The strange part about it, it's that you don't even have to perform requests with tools like ab or wrk. It just leaks even without ever hitting http://localhost:1337

@soyuka
Copy link
Collaborator

soyuka commented Jul 28, 2015

balderdashy/sails#3099

@shumailarshad
Copy link
Author

Just to add. As @soyuka mentioned that issue I opened with sails. It seems to behave correctly if we turn off sockets, pubsub in .sailsrc file. But I still don't understand cause of the issue.

@soyuka
Copy link
Collaborator

soyuka commented Jul 29, 2015

I've done a few tests with express, sails and a basic http server :

Basic http server :

basic

Express server :

express

Sails server :

sails

Sails seems to be clearly leaking.

More infos : https://github.com/soyuka/nodejs-http-memtest

@soyuka
Copy link
Collaborator

soyuka commented Jul 29, 2015

Closing as a non-pm2 issue

@soyuka soyuka closed this as completed Jul 29, 2015
@jshkurti
Copy link
Contributor

Great work @soyuka 👍

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

No branches or pull requests

4 participants