-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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 Ruby gem as of 3.15.x #8421
Comments
Thanks for the report. Can you confirm which version of Ruby you are using? |
Hi @haberman ! This happened on 2.6.6 in Debian Buster; however, I can confirm it also happens on 2.4.x as well:
But not Ruby 2.7.0:
|
May have spoken a bit too soon. I've added CircleCI build results for 2.4->2.7 on the repo I listed above that runs the tests: https://app.circleci.com/pipelines/github/splittingred/protobuf-315-leak?branch=main You can see the individual results for each Ruby version there. The impact in 2.7 is much less; however, it is still there. |
Thanks, knowing that 2.7 is much better will help narrow this down a lot. |
Hi @haberman - thanks for the fix. This still seems to be happening on 3.15.7, however:
I've updated https://github.com/splittingred/protobuf-315-leak to test against 3.14, 3.15.6, and 3.15.7. |
Hi @splittingred, thanks for the update and sorry this hasn't been fully resolved yet. I have some good news: I found a far more straightforward memory leak that has been present since 3.15. The issue affects all versions of Ruby equally, and the fix is very simple. We should release this fix very soon. However I want to offer a slight bit of caution: even this fix will not take your benchmark to "0 retained" for Ruby <2.7. Versions of Ruby prior to 2.7 have a deficient implementation of The extra retained memory should not grow without bound though. In particular, the graph you posted in your original message, where the memory grows without bound, should no longer happen. |
Fix for this was merged via #8461 but for some reason github did not auto-close this issue. |
This is hitting a large number of our apps as well, currently doing restarts every 9hrs to keep from OOM. I see the fix is in and there is an RC release. Would you all recommend trying the RC release or will a main line be cut soon? |
@danmayer 3.15.8 just hit Ruby Gems, which contains the fix: https://rubygems.org/gems/google-protobuf/versions/3.15.8-x86_64-linux |
Hi @haberman - just to follow up here, I ran this against our benchmark, and it was essentially unchanged from 3.15.7 to 3.15.8.
Furthermore, these numbers scale linearly with request counts:
You can see the results here: https://app.circleci.com/pipelines/github/splittingred/protobuf-315-leak I've also updated the repository I used for testing here: https://github.com/splittingred/protobuf-315-leak Would you expect that to be the case? I'm a bit concerned about putting protobuf 3.15.x on live code to see how it performs in the wild given the linear memory increase here; and all my internal load testing shows the 1:1 scale. |
What version of protobuf and what language are you using?
Version: 3.15.6
Language: Ruby
What operating system (Linux, Windows, ...) and version?
MacOS Catalina, Linux (Debian Buster).
What runtime / compiler are you using (e.g., python version or gcc version)
N/A
What did you do?
We have noticed a memory leak in the google-protobuf gem as of 3.15, when used in a gRPC server. Rolling back to 3.14 fixes the issue. See an example graph:
The 2nd section there shows when google-protobuf 3.15 was deployed; there is a small section after showing normalization of memory after reverting back to 3.14.
In order to eliminate potential other libraries, I wrote a quick benchmarking test doing a small client->server unary call. This runs a benchmark using memory-benchmark to run against Protobuf 3.14 and Protobuf 3.15. The results showed a significant number of objects being retained (and increased memory usage) when run with 1,000 requests on protobuf 3.15, but no such leakage on protobuf 3.14:
You can run this test and see the code for it here: https://github.com/splittingred/protobuf-315-leak
What did you expect to see
No memory leak or runaway usage.
Anything else we should know about your project / environment
This occurs both on mac os x, and also in a dockerized Debian Buster container environment.
The text was updated successfully, but these errors were encountered: