-
Notifications
You must be signed in to change notification settings - Fork 200
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 in feed view? #320
Comments
Hey @tomcardoso, Thanks for digging into Klaxon! I'm not sure what you're seeing is a memory leak here. It's hard to tell from the cropped screenshot why Heroku might have restarted the server, but they do typically restart free servers once a day as a matter of course, and the second restart looks like a deploy. Typically Heroku doesn't forcibly restart your dyno until you hit 200% maximum memory, although they may be less forgiving for free dynos, I'm not sure. The way a typically rails application works, it will ask for memory as it needs more, and then not give it back to the system, handling garbage collection internally, at least up to some cap. I'm not totally sure why that particular view would be guzzling so much memory, but I don't see anything inherently alarming about this pattern. Hard for me to tell what all is going on here, but looking at our own klaxon instances I don't see any major cause for concern. |
I'll dig into it a bit and get back to you. My past experience with Rails apps (both ones I've built myself and external ones I've deployed) has taught me it tends to be pretty leaky, so if this actually happening here it wouldn't surprise me. On the Changes controller, I did notice that it seems like all page snapshot objects are being assigned to a variable that never gets used. Since a new controller gets created for every request, I imagine this might be bogging things down a bit: https://github.com/themarshallproject/klaxon/blob/develop/app/controllers/changes_controller.rb#L10 |
But the controller is also disposed of when a request ends, right? I'm not sure why that would constitute a memory leak, unless the framework itself is somehow flawed. You're right though that that data does not need to be loaded there. |
I'm seeing the app restart every hour or so due to running out of memory. The memory usage chart looks like a classic memory leak:
I installed Scout APM to track down what might be causing it. It seems calling WatchingController#feed adds 16mb each time it's called. A breakdown suggests that the feed change template is responsible:
https://github.com/themarshallproject/klaxon/blob/develop/app/views/watching/_feed_change.html.erb
Same thing with this Changes template:
https://github.com/themarshallproject/klaxon/blob/develop/app/views/changes/page.html.erb
I'm no expert with memory leaks in Rails, but happy to help try and track this down if someone's able to help.
The text was updated successfully, but these errors were encountered: