sails: Memory Leak in sails-mongo
Waterline version:0.10.26 Node version:0.10.33 && 4.3.1 NPM version:1.4.28 Operating system:Windows 7 x64 && Ubuntu 14.04.3 LTS
Referencing #1319
https://github.com/rootinc/waterline-test
Steps to reproduce bug:
- Clone the Repo
- Run
sails lift - Put something in the DB by running this in the browser:
http://localhost:1337/test/create?name=Hello - Reload this link over and over and watch the memory leak:
http://localhost:1337/testthis/<newId>
OR
- Make a vanilla sails app.
- Then run
sails generate api Test - In TestController, add route that looks like this:
testGet:function(req,res) { var testId = req.param(‘testId’); Test.findOneById(testId).then(function(test){ res.send(“Hi”); }); } - In Test.js (model), added property
schema:true, and property callednamethat is required and a string. - In route.js, added this
'get /testthis/:testId' : 'TestController.testGet' - In models.js, uncomment
migrate:'alter' - Reboot the server running
sails lift - Put something in the DB by running this in the browser:
http://localhost:1337/test/create?name=Hello - Reload this link over and over and watch the memory leak:
http://localhost:1337/testthis/<newId>
For the time being, I am invoking global.gc every 15 minutes to clean up some memory. That seems help, but I know that is not a permanent solution.
Any assistance on this would be great. Thanks!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (8 by maintainers)
Commits related to this issue
- Add error handling (see https://github.com/balderdashy/waterline/issues/1323#issuecomment-195777298) — committed to mikermcneil/waterline-test-danieltjewett by mikermcneil 8 years ago
A few things to make sure you are paying attention to. The default session store is
memoryso without moving that to something likeconnect-redisthe process will eat up more and more memory and not release it.Running a test on:
node@4.2.2sails@0.12.3sails-mongo@0.12.0connect-redis@3.0.2I used the example project posted above and
abto send it millions of requests. Here are the graphs I got back and after running all the requests I manually ran the garbage collector and ended up with heap usage and rss usage lower than when I started the process.There are more postings here and here. These screenshots are only from a 15 min block but over the course of a few hours they remain relatively stable. With a memory leak you would see a clear trend upwards and I just haven’t seen anything like that.
For this I would try re-creating it with a fresh Sails project making sure the
NODE_ENVis set to production and the session and socket stores are setup for production use.