-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #4264
Comments
Hi @berge616! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:
As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks! *If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com |
fixed |
@berge616 Thanks for posting, we'll take a look as soon as possible. For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here. |
Original thread from Gitter: https://gitter.im/balderdashy/sails?at=5a32e1a1a2be466828a140c6 Kyle will try commenting out those debugs and seeing if it fixes the issue... |
Commented out those debug lines along with similiar ones in identically named files from machinepack-mysql and the leak is fixed. Confirmed by observing dumps after removal of Debug lines |
Thanks @berge616! |
@mikermcneil posted to Trello as https://trello.com/c/IzkNTeO7/404-machine-runner-memory-leak |
@berge616 @sgress454 thanks! And @sgress454 that plan in Trello sounds good, though in the latest runner, we're not actually using the @berge616 For the mp-mysql stuff, assuming this is about the query logs, just to make sure: Were you using NODE_ENV=production when you tested this? I took a look at potential issues from |
@mikermcneil These are debug calls inside of machine runner (see line numbers in original post), and they're made regardless of environment (they just don't actually output anything if you don't set the DEBUG env var). So the issue seems to be that a new debug instance is made on every run, where typically we just create a single instance when we first require |
For the sake of clarity, contrast the use of debug in https://github.com/node-machine/machine/blob/13.0/lib/private/intercept-exit-callbacks.js#L260-L261 with how it's used in Skipper, here: https://github.com/balderdashy/skipper/blob/bcf5451ca9d6f1f8763425ac5962531b719116b7/standalone/Upstream/prototype._read.js |
@mikermcneil yes this is with the env set to production. They for sure linger forever. Spin up a new sails project with mysql db and hit it with a load test. You'll see the memory grow indefinitely even with GC running. Each debug stmt takes up ~300 bytes and with each api call calling the db a handful of times, this adds up pretty quick. |
@berge616 @sgress454 just pushed up experimental upgrades to mp-mysql and sails-mysql in balderdashy/sails-mysql@075d759 and sailshq/machinepack-mysql@d9d31aa To test:
|
@mikermcneil are there any breaking changes for this newer version? I'm getting this error when I try it out:
|
@berge616 there are! Thanks for pointing that out-- I should have caught it. Pushed sailshq/machinepack-mysql@8660bf0 and balderdashy/sails-mysql@5e8ed7e Caveat: I thought I'd nabbed them all the first time when I took care of example->outputExample, etc, but I haven't had time to go much past quickly running a couple of tests yet, so it'd be great to hear if you see any other compatibility issues trying it out in practice with the repos linked |
@mikermcneil Thanks for fixing that. The debug() memory leak is gone! I ran through all my tests and everything looks good. Any timeline for getting this released? |
@berge616 awesome! Thanks for checking. It'll technically be a breaking change to mp-mysql, so I went ahead and published 3.0.0 of that. I'll try pointing sails-mysql at it to make sure all the tests pass. Assuming that looks good, ready whenever |
LGTM - published sails-mysql@1.0.0-16 (please give that a shot and let me know if you run into any issues!) |
After 1.0.0-16 sendNativeQuery is not working. https://next.sailsjs.com/documentation/reference/waterline-orm/datastores/send-native-query Promise never resolves. |
Hi, i am also focusing on this memory leak issue. transaction: function(req, res) { on sails-mysql@1.0.0-15, it print "start" and "end" correctly. |
Sails version:1.0.0-12
Node version:8.9.3
NPM version:5.5.1
DB adapter name: sails-mysql
DB adapter version: 1.0.0-15
Operating system:na
https://github.com/node-machine/machine/issues/46
--Copied below:
There is a memory leak in this module when called through sails-mysql. The above image shows the memory leak on a system with 768mb ram. The ECS container gets kicked when it reaches its max so that's why the sawtooth. This is a low use system so this memory leak is quite significant. Reproduced locally with a fresh sails project and took heap snapshots before any calls and then after running many calls through the api. Compared these heaps in chromes profiling and found an alarming number of debug closures being left in memory(both snapshots were taken immediately after forcing a garbage collection)
This is easily reproducible by installing sails v1 and connecting it to a mysql db with some basic routes to add a record to the db.
Here is the code i used to get heap size and generate the snapshots:
These lines seem to be the culprit:
https://github.com/node-machine/machine/blob/13.0/lib/private/intercept-exit-callbacks.js#L260-L261
https://github.com/node-machine/machine/blob/13.0/lib/private/help-exec-machine-instance.js#L108-L110
I'm using the following versions:
The text was updated successfully, but these errors were encountered: